DEV Community

Discussion on: ES6 for beginners with example

kjellski profile image
Kjell Otto

Nice post and good examples, thanks! Although I don't understand why so many examples use let over const. I think it's better to use const wherever you can. Is there a reason to consider the opposite?

reegodev profile image
Matteo Rigon

Because let will never throw an error and is seen as the successor of var, while const is more restrictive.
You are right though, as long as you write ES6 always use const unless you see you explicitly need to change the variable reference, like for counters and booleans