In a browser, what does 'this' refer to in a regular function call in non-strict mode?

The story behind the answer

In a browser, `this` refers to `window` in a regular function call made in non-strict mode. For a direct call such as `showContext()`, JavaScript supplies the global object as the function’s `this` value rather than the function itself.

This behavior follows JavaScript’s call-site-based rules for regular functions. In a browser’s classic script environment, the global object is `window`, which also provides access to many browser-wide features. In strict mode, the same direct call instead gives `this` the value `undefined`.

The result changes when the call form changes. In `obj.method()`, `this` is `obj`; when a function is used with `new`, `this` is the newly created object. A DOM event handler may receive the element that triggered the event, depending on how the handler is registered.

Arrow functions are another common source of confusion: they do not create their own dynamic `this`. They capture it lexically from the surrounding scope. Code that needs the global object reliably can use `globalThis`, which works across browser and non-browser JavaScript environments.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: