But with the coming of the ES6 version, the functionality arrived and the reserved word for this instruction is const
In this way, we can natively create a constant, that is, a variable that cannot have its value changed, only assigned when it is created.
See an example:
const nome = "Matheus";
In addition, the let statement, which creates a variable that can have its value changed, has also been added.
The two have one characteristic in common, their scope is created in any block
But that’s a topic for another post hehe
Beware of Compatibility
ES6 features are not yet fully standardized across all browsers
This can make your code non-functional in some of them, the most problematic is Internet Explorer
So if your application has to guarantee compatibility, you can look for some JS code transpiler
Like Babel, which will transform your code into standardized JS and then it can be used on all sites without any problems =)
We use the const statement, which creates a variable whose values cannot be changed (constant concept)
However, it is an ES6 feature, that is, it is not standardized in all browsers.
To solve this problem you can use a transipile, which will standardize your code to be used in any browser