3 ms·
> To alter globals, use the window object explicitly. JS is used in non-DOM contexts as well. Though, of course, if that big a change is being made, a generic
by hrjet 11y ago
> To alter globals, use the window object explicitly.
JS is used in non-DOM contexts as well. Though, of course, if that big a change is being made, a generic substitute for `window` could also be specified.
- reubenmorais 11y ago> a generic substitute for `window` could also be specified Isn't that just |this| at the top level?
- singlow 11y agoNot necessarily the _top_ level if you are referring to scope. `this` will be the default global unless another context is defined, whether you are at the top level or inside a function. In node, there is a name for the default global: "global", which is also the default context. So node gives it a "generic substitute" as the OP suggested. Most people use "this" to make assignments to it, rather than the "global" name, since it is usually accessed from the default context.
- deleted 11y ago[deleted]