4 ms·
I don't understand why they need access to global variables. If you are writing a portable module using strict mode, you should't need access to "window" or "gl
by codedokode 7y ago
I don't understand why they need access to global variables. If you are writing a portable module using strict mode, you should't need access to "window" or "global". If you are writing non-portable code then you can access "window" or "global" by its name.
I mean, they intentionally closed access to global object through "this" in strict mode and now they want it back.
- amitport 7y agowould you prefer the current: (?) let global = typeof window === 'undefined' ? global : window // do something with global.theGlobalProp (this is used to refer to currently available globals which are not going away anytime soon)
- Uehreka 7y agoCan’t you use `self` to refer to the global object in both client and server contexts?
- LocalPCGuy 7y agoThe article goes into why you can't just use `self`
- IgorPartola 7y agoI would rather do: export default foo(theGlobalProp) {...; return ...;} Why should a module reach outside its own scope?
- deleted 7y ago[deleted]