var

有没有var有什么区别?

1
2
var1 = "var1111"; //make sure typeof var1 === "undefined"
var var2 = "var2222";
  1. 这是第一个区别

    所以,你可以 delete var1

  2. 第二个区别

  • var1 实际是 Host.var1 (浏览器中,HOST就是window;node中,HOST就是global)
  • var2 实际是 VE.var2,(And what is VE ? 一个数据结构,此时是window,我很可能错了。感觉自己在放屁,TBC。)

看看 Object

this,这里是 window。)

所以,你可以 delete Object;在window中你也看不到 Object;对不起,我骗了你,在 [default properties]确实有 Object;其实是当我 for (var p in window)时,p不到Object

再抄点东西吧

A var statement declares variables that are scoped to the running execution context’s VariableEnvironment.