Properties on window are global variables

Properties on window are global variables. Global variables are properties on window. The global object, (we're talking about it as window, but `global` in node is the same) is where scope, invocation context, inheritance, and property access all come crashing together.

function wow () { this.really = '???' } wow() console.log(really) // '???'

It doesn't matter how you get the reference to the global object, writing a property to it still makes a global variable. It works the other way too, if you forget a var statement that will show up as a property off of window.

One of the easiest ways to accidentally write to the global object is to use `this` in a function that gets invoked in the global context. In our case above, we could expect wow to get added as a method of an object, and always called like that. Or we could expect it to always be called with new, so we'd be adding ready to a newly created object. However, we call it in the global context (not as a method, not with new, not explicitly setting the context), so we create a global variable by writing to `this` which is the same as window/global.

Just be aware that you don't want to go stashing things on the window object using common names, because those properties become global variables in your entire app. If you are getting weird behavior with state sticking around where you thought it was impossible, make sure that your 'this' doesn't actually turn out to be the global object when you don't mean it to be.