【发布时间】:2015-06-25 13:28:47
【问题描述】:
我从下面给出的MDN website 修改了原始脚本。
var 的类型是什么?是不是在给变量赋值后才赋值的类型。
var b = 1是否会覆盖前面的语句var b = 10?还是只是变量 b?是否让非标准语言功能?我读到 here 它在 ECMAScript 6 中受支持。
var a = 5;
var b = 10;
if (a === 5) {
let a = 4; // The scope is inside the if-block
var b = 1; // The scope is inside the function
alert(a); // 4
alert(b); // 1
}
alert(a); // 5
alert(b); // 1
【问题讨论】:
-
ECMAScript 6 是一个即将推出的标准,它还没有得到广泛的支持,而且还不完整,所以它仍有可能发生变化。
-
变量没有类型。价值观。
标签: javascript var let