ES6, the distinction var, let the const and
Others
2019-08-01 23:54:55
views: null
var features
- There is no concept of code blocks, globally valid
- There is "variable lift" phenomenon, that can be used before variable declarations, value is undefined
let's features
- Variables declared valid only within the block-level action, the presence of the concept of block
- There is no "variable lift" phenomenon
- There is a temporary dead zone, before the tmp variable that is declared, all belong tmp "dead zone"
- Not allowed to repeat a statement
const features
- Once the modified identifier to be assigned const, can not be modified
const name = 'Why';
name = 'ABC'; // will complain
- Use const definition identifier must be assigned
const name; // will complain
- The meaning of the object pointed constant is not modified, but the attribute of an object can change
const obj = {name: 'XXX', Age: 18 is}
obj.name = 'AAA';
obj.age = 20 is; // this is not being given
Origin www.cnblogs.com/adongyo/p/11284363.html