The third declaration class keyword introduced by ES6 is similar to let: Const.
Take a look at the usage:
Const C1 = 1;
Const C2 = {};
CONST C3 = [];
Object.getownpropertydescriptor (window, "C1")
//object {value:1, Writable:false, Enumerable:true, configurable: False
The above example says that you can't assign a value to a C2, but you can change the contents of C2 because C2 is an object, see example:
Also, you can add elements to the C3 because C3 is a number of arrays.
The const declaration constant also has the problem that the declaration and initialization must be together and declared to be initialized:
' Use strict ';
Const C4;//uncaught syntaxerror:unexpected token;
Remove the semicolon will still be an error, we do not discuss the situation under strict mode, interested in the can go to try.
The variables of the const declaration are similar to those of let declarations, and they differ in that the const declared variable can only be assigned at the time of declaration and cannot be modified arbitrarily, otherwise it can cause syntaxerror (syntax error).
Const MAX_CAT_SIZE_KG = 3000; Correct
max_cat_size_kg = 5000;//Syntax error (SYNTAXERROR)
max_cat_size_kg++;//Though changed in one way, it still causes grammatical errors
Of course, the specification design is wise enough to declare a variable with a const must be assigned a value, or else throw a syntax error.
Const Thefairest; It's still a grammatical mistake, you miserable bastard.