Re:JavaScript variables: var and let and const
by neurotrace on Friday March 06, 2020 @07:13PM
(#22508631)
If you really, really need a global then you should assign it to `window/global/globalThis` instead of relying on the weird behavior of `var`
[ Parent
| on HN ]
Re:JavaScript variables: var and let and const
by wolco on Saturday March 07, 2020 @04:16AM
(#22510740)
What do you find weird about var?
Re:JavaScript variables: var and let and const
by DaiPlusPlus on Monday March 09, 2020 @04:22AM
(#22523834)
It's weird because it has side-effects (namely, implicitly adding/setting a named property in the current scope object, if any).
It means that a top-level script using `var` that is subsequently refactored into a scoped function somewhere will now have different semantics and might break if other code depended on `var` creating a new global property.