ES proposal: global
The ECMAScript proposal “ global ” by Jordan Harband is currently at stage 3. It provides a new standard way of accessing the global object. Referring to the global object The following are a few popular ways of referring to the global object: Global variables: Global variable window : is the classic way of referring to the global object. But it doesn’t work in Node.js and in Web Workers. Global variable self : is available in Web Workers and browsers in general. But it isn’t supported by Node.js. Some people use self to mark code that works in both Web Workers and normal browser contexts. Global variable global : is only available in Node.js. Until now! this : this in global scope: refers to the global object. The only problem is that Node.js modules and ES6 modules have their own scopes, which means that this approach doesn’t work there. this during a function call in sloppy mode: If you call a function via a function call (and not a method call), its this refers to the global ob...