r/learnjavascript • • May 04 '20

VAR vs LET vs CONST

Post image
337 Upvotes

81 comments sorted by

View all comments

3

u/[deleted] May 04 '20

Any specific reason to not use const and let in the global scope? My introduction to JavaScript was in a college class and the instructor almost exclusively used let while now I'm using Codecademy online to learn more and it, at least so far almost exclusively used const unless there it plan to change it in which case it uses let. I don't think I've ever actually used var.

Edit: changed a word

1

u/[deleted] May 04 '20

Dan Abramov recommends only using let, for what it's worth.

1

u/HeinousTugboat May 04 '20

What's his reasoning behind that? He hates letting optimizing compilers optimize?

1

u/[deleted] May 05 '20

It had to do with const not really preventing the contents from being changed. It is not really constant. If a developer assumes that constants really are constant then it might lead to bugs.