已废弃
在ES6最终确定之前,
let
语句的块级版本被删除了,并且支持它的浏览器也已将其删除。这个问题现在只具有历史意义。
使用ECMAScript 6 let
块级语句和使用等效对象文字的with
语句是否有区别?
使用let
语句
var x = 10;
let (x = x * 10,
y = x + 5) {
console.log("x is " + x + ", y is " + y);
}
使用 with
语句
var x = 10;
with ({x: x * 10,
y: x + 5}) {
console.log("x is " + x + ", y is " + y);
// writes "x is 100, y is 15"
}
with
进行作用域限定? - Ruan Mendes