同时定义多个变量
let a;
let e, b, c;
let name = ‘nb‘, age = 18, height = [];
变量不能重复声明,使用var
却可以!
// 变量不能重复声明
let school = ‘xd‘
let school = ‘nb‘
var test_school = ‘xd‘
var test_school = ‘nb‘
let 拥有块级作用域,var属于全局变量!
{
let sex = ‘男‘;
var test_sex = ‘女‘
}
console.log(sex)
console.log(test_sex)
结果:
原文:https://www.cnblogs.com/NB01/p/14226503.html