We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
let const 是ES6中新增的声明变量的关键字。 1、let let 声明的变量具有如下特性:
// let 的情况 console.log(b); // 报错ReferenceError let b = 2;
if (true) { // TDZ开始 tmp = 'abc'; // ReferenceError console.log(tmp); // ReferenceError let tmp; // TDZ结束 console.log(tmp); // undefined tmp = 123; console.log(tmp); // 123 }
let a= 1; let a = 1; // Uncaught SyntaxError: Identifier 'a' has already been declared
2、const const 声明的变量具有如下特性:
const num = 10; num = 11; // Uncaught TypeError: Assignment to constant variable const obj = {a: 1}; obj.b = 2; console.log(obj); // {a: 1, b: 1} <!--对obj 重新赋值--> obj = {c: 3}; // Uncaught TypeError: Assignment to constant variable
3、var var 声明的变量具有如下特性:
// var 的情况 var a =1; var a = 2; console.log(a); // 输出2
// var 的情况 console.log(a); // 输出undefined var a = 2;
The text was updated successfully, but these errors were encountered:
No branches or pull requests
let const 是ES6中新增的声明变量的关键字。
1、let
let 声明的变量具有如下特性:
2、const
const 声明的变量具有如下特性:
3、var
var 声明的变量具有如下特性:
The text was updated successfully, but these errors were encountered: