We all are familiar with the difference between const, let and var. If not, please read this.
So now, what we are left with, is the
People believe their ways of using them both. Strongly.
Here are the two types of people.
1) Those who use
const for Constants (Like for
const PI = 3.14)
2) Those who use
const for everything that won't be let
Some people believe that
const should only be used for strictly constant values like the Action Type Reducer Strings, Math values and constants like PI, etc.
If you are that person, you are from team CONSTANT SPARINGLY.
If you always use
const, no matter what, and only use
let when you change a variable, you are from team CONSTANT FOR ALL.
There has been a lot of talk around it on Twitter due to this tweet by Dan Abramov.
Dan AbramovTC39 members: const was a mistake.
The tweet pretty much sums up that he is from the team CONSTANT SPARINGLY.
If you have been seeing WesBos' tutorials, he seems like he is from the team CONSTANT FOR ALL.
Dan has provided a beautiful explanation for why he thinks const shouldn't be used.
Also, this writeup here focuses on easily concluding this discussion. But still, what's your opinion on it?
What do you prefer? Let's Discuss!