3 ms·
> that the global namespace should be `window`, because that's what it is in JavaScript's natural habitat. Oh wow, I had no idea. That rules!
by danbolt 5y ago
> that the global namespace should be `window`, because that's what it is in JavaScript's natural habitat.
Oh wow, I had no idea. That rules!
- afiori 5y agoecmascript now has both `globalThis` and `self` that can act as global namespace (they all point to the same object except in workers as window and globalThis cannot be used in workers)
- moron4hire 5y agoNo, `globalThis` is available in workers. It points to `self`. On the page, `globalThis` points to `window`. `globalThis` thus becomes the one, safe, global reference you can make for code that runs in both pages and workers.