Do let statements create properties on the global object?

前端 未结 5 509
囚心锁ツ
囚心锁ツ 2020-11-22 01:11

In JavaScript, var declarations create properties on the global object:

var x = 15;
console.log(window.x); // logs 15 in browser
console.log(glo         


        
5条回答
  •  无人共我
    2020-11-22 01:35

    Variables declared via let keyword do not create accessible properties on a global object (window for a browser). Actually, Firefox fixed its behavior: let v = 42; 'v' in window // false

提交回复
热议问题