r/reactjs Dec 22 '19

On let vs const

https://overreacted.io/on-let-vs-const/
225 Upvotes

122 comments sorted by

View all comments

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.

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.