5 ms·
would you prefer the current: (?) let global = typeof window === 'undefined' ? global : window // do something with global.theGlobalProp (this is used to ref
by amitport 7y ago
would 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]