Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Support global as alias of globalThis where possible #36

Closed
ExE-Boss opened this issue Dec 19, 2018 · 2 comments
Closed

Support global as alias of globalThis where possible #36

ExE-Boss opened this issue Dec 19, 2018 · 2 comments

Comments

@ExE-Boss
Copy link

ExE-Boss commented Dec 19, 2018

The main reasoning is that this is very confusing in the context of JavaScript due to it being a horrible mess that was originally created by a single developer for Netscape Navigator.

See also #31 for more reasoning.

(I really, really hate the name globalThis, even more than using window and I much prefer the technological purity of plain global)

At the very least, I would want global to be supported in modules by default.


Because of the above, I tend to do:

if (!("global" in window) || global !== window) {
	Object.defineProperty(window, "global", {
		get() {
			return window;
		}
	});
}

Then, I just use global as alias of window.

@ljharb
Copy link
Member

ljharb commented Dec 19, 2018

Thanks for your feedback!

global is not web-compatible, in Scripts or Modules, because it's used as environment detection (to distinguish node and browsers). Please see the list of constraints for more information: https://github.com/tc39/proposal-global/blob/master/NAMING.md

@ExE-Boss
Copy link
Author

ExE-Boss commented Dec 19, 2018

I still prefer, and will keep using, global over globalThis.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants