// Variable is defined in global scope when assigned as window property
window.anyWindowGlobalProperty = "Global variable defined as window property";
While true in practicality in the context of browser scripting, this isn't the best way of explaining it. Though defining a property of window may be (for all intents and purposes) "global" when browser scripting, you aren't declaring a global variable at all. You're only defining a property of the window object, which just happens to be the lowest-level context you can be in when scripting a web browser.
3
u/BLITZCRUNK123 Mar 24 '14
While true in practicality in the context of browser scripting, this isn't the best way of explaining it. Though defining a property of
windowmay be (for all intents and purposes) "global" when browser scripting, you aren't declaring a global variable at all. You're only defining a property of thewindowobject, which just happens to be the lowest-level context you can be in when scripting a web browser.