We can store data using three types of keyword var let const

Note: The browser preparses the program before it executes,

There was no block-level scope before ES6 syntax.

1. The undeclared variable is called the constant name = “You” which belongs to the window value

2. Variable naming should follow the following points:

Variable names must contain only letters, numbers, and the symbols $and _,

The first character must be non-numeric, cannot be system keyword, reserved word as variable name.

3. Var is defined as a local variable in the method, but is declared as a global variable in the global domain, and the var declaration will generate variable promotion.

4. Let declares variables and the let declaration is valid only for the current code block (Example 1), resulting in block-level scope (Example 1), no promotion of variables, and a temporary dead zone (Example 2) if variables are used before they are declared.

5. Const Declares a read-only constant. Once declared, the value of a constant cannot be changed. This applies only to basic data types, but complex data types can be changed.

Freeze properties (Example 4) Do not allow repeated assignments (Example 3).

Example 1:{let foo = 10; var bar = 10; } console.log(foo) // ReferenceError: A is not defined.console. log(bar) //10 let num = 5 if(true) {let num = 10 console.log(num) //10} example 2:funciton foo(){ Console. log(a) // ReferenceError let a = 10} var a = 10; Let foo = 10 object.freeze (foo) // No one can touch meCopy the code