When reading javascript Advanced Programming (page194), the differences between global variables (variables declared with var in window environment) and global attributes (attributes defined directly on window objects) are introduced. Global variables are not deleted by delete attribute, and global attributes can be deleted by delete. However, global variables can be accessed through global attributes. So there is a little doubt. Both functions are similar.ECMA
The intention of this design is What?
First of all,Strongly recommendedThis post,understand delete
Next, we need to know what isGloblobject and window,execution context, andvariable object/activation objectFull stop
When passed
Var
Or ..Function
When defining variable or function, they become the property of globlobject, and they also haveDontDeleteAttribute of. Since he is a property of globobabject, of course he can passwindow.aProp
To visit la.And,
window.foo = 1
If this display defines a property for an object, the property does not haveDontDelteThe of this attribute.As long as there isDontDelete, cannot be
Delete
Operator delete.Reference: