Awesome! This theoretically makes it easier to write universal libraries and apps. Naming it global would break existing websites but naming it globalThis seems almost hacky. Also, for this to really work as part of the language, libraries need to utilize it.
-
-
-
“Global this” might sound weird at first, but it is the technically-most-correct name: https://mathiasbynens.be/notes/globalthis#terminology …
- 2 more replies
New conversation -
-
-
I'd prefer something like 'root' in this case.
-
We all wanted `global` but unfortunately that name wasn't web-compatible. https://github.com/tc39/proposal-global/blob/master/NAMING.md#names-ruled-out-by-this-restriction-4 …
End of conversation
New conversation -
-
-
There was a lot of outrage when the wider JS community first got wind of the name and there were some lackluster attempts to prevent this but in the end globalThis won. Most of the favorites were ruled out because of UMD (thanks for nothing, UMD).
-
All the “good” names had to be ruled out, unfortunately, since they were already in use in existing code, and we can’t break back-compat. We all wanted `global` (we tried!) but it just wasn’t possible. IMHO any name is fine. What matters most is having the functionality.
- 1 more reply
New conversation -
-
-
Woohoo, no more ugly Function('return this')().
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Is there any proposal to support something like sharedGlobalThis? Global that will be shared between DOM, Web Workers and Service Workers...pic.twitter.com/uBe62yaPRa
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
So many issues I've come across with SSR are related to bugs with libraries getting the global this context. Hopefully this helps fix that.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
What is this
-
Exactly what is this ?
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.
globalThis is available in Chrome, Firefox, Safari, and Node.js!