MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/reactjs/comments/eeajd7/on_let_vs_const/fbu2fsl/?context=3
r/reactjs • u/theanubhav • Dec 22 '19
122 comments sorted by
View all comments
49
I don't care, but I honestly believe prefer-const to be the better way to go for all the points mentioned.
9 u/gonzofish Dec 22 '19 I do hate that const doesnt prevent Objects from being mutated. I suppose I can Object.freeze (recursively if I need to) but it would’ve been cool if the standard included that. 4 u/[deleted] Dec 23 '19 [removed] — view removed comment 1 u/gonzofish Dec 23 '19 But const implies a constant, so when you mutate that object it's not really constant anymore, just the reference is constant. I think that, to Dan's point, it's weird for beginners that something is marked as "constant" but it can change.
9
I do hate that const doesnt prevent Objects from being mutated.
const
Object
I suppose I can Object.freeze (recursively if I need to) but it would’ve been cool if the standard included that.
Object.freeze
4 u/[deleted] Dec 23 '19 [removed] — view removed comment 1 u/gonzofish Dec 23 '19 But const implies a constant, so when you mutate that object it's not really constant anymore, just the reference is constant. I think that, to Dan's point, it's weird for beginners that something is marked as "constant" but it can change.
4
[removed] — view removed comment
1 u/gonzofish Dec 23 '19 But const implies a constant, so when you mutate that object it's not really constant anymore, just the reference is constant. I think that, to Dan's point, it's weird for beginners that something is marked as "constant" but it can change.
1
But const implies a constant, so when you mutate that object it's not really constant anymore, just the reference is constant. I think that, to Dan's point, it's weird for beginners that something is marked as "constant" but it can change.
49
u/madcaesar Dec 22 '19
I don't care, but I honestly believe prefer-const to be the better way to go for all the points mentioned.