When a function is called without context (and you are running in non-strict mode) this defaults to the global object.
In a browser the top-level of your source code runs in the global context, so this.a, which is window.a is the same as the var a declared in the global context at the top. Assigning this.a = 1 is the same as assigning a = 1.
In node.js each JavaScript file gets its own module context that is separate from the global context, so var a = 0; is not creating a global, and the global you created with this.a = 1; will be shadowed by the modules own a.
window). Try console loggingthis, and it should become clear.