global while in browsers you’d use
window (despite that being a WindowProxy and not the actual global object, which is not directly accessible in browsers). In other places like with web workers, you don’t have either, instead relying on a
self property in the top level context.
self also exists in normal browser code, referencing the
window object, but it does not exist in Node.
The introduction of
this in the global context. As we’ve seen with browsers this isn’t exactly the global object, instead being a WindowProxy, but, you know, close enough.
// in browsers (non-module, top level) console.log(globalThis === this); // true console.log(globalThis === window); // true // in Node (non-module, top level) console.log(globalThis === this); // true console.log(globalThis === global); // true