Dler Ari
1 min readMay 18, 2018

--

You can of course use let. However, if you work in a team, you will most likely encounter someone that changes your value without even being aware of it. For instance, if you define an array and call it listOfItems (I don’t recommend given such names, but this is just to prove an example), then someone decides to also create an array and give it the same name. If you use let, then that person will replace your array. However, if you use const, he will get an error when trying to change that array with name listOfItems. In terms of protection and preventing changes on critical values, go for const.

A rule of thumb is, use const always, and if you want to change the value, simply use let.

Check out this great article about var, let and const by Eric Elliott, click here

This is why I favor `const` over `let` in ES6. In JavaScript, `const` means that the identifier can’t be reassigned...

--

--

Dler Ari
Dler Ari

Written by Dler Ari

Software Engineer sharing interesting tech topics

No responses yet