【发布时间】:2017-06-10 10:08:40
【问题描述】:
我在全局范围内创建了一个导航器变量,并使用let 关键字为其分配了一个字符串。
// in a browser
let navigator = "Hello!";
console.log(navigator ); // "Hello!"
console.log(window.navigator === navigator ); // false
这里let navigator 的值会影响window.navigator。但我很想知道let navigator 到底存储在哪里?
【问题讨论】:
-
Mozilla 像这样描述here:
Global let ... live in the scope of an invisible block that notionally encloses all JS code that runs in a web page.
标签: javascript ecmascript-6 let