Interview Q&A / JavaScript

IntermediateQuick answer1 min readUpdated 3 Oct 2026

What is this inside a plain function call in strict mode versus sloppy mode?

SHORT ANSWER

In sloppy mode a plain call gets the global object as this. In strict mode it gets undefined. Strict mode also stops call from boxing a primitive this into an object.

Explain it simply

When there is no object before the dot and no call, apply or bind, this falls back to a default. Sloppy (the old, forgiving mode) picks the global object, which makes it easy to read or write global variables by accident. Strict mode picks undefined, so a mistake fails loudly instead of silently touching globals.

You get strict mode with "use strict", inside class bodies and inside ES modules, so most modern code already runs in it.

Strict mode also changes primitives: fn.call(5) gives this as the number 5, while sloppy mode wraps it as a Number object.

Example

js
function strictFn() {
  "use strict";
  return this;
}
console.log(String(strictFn()));          // Output: undefined
console.log(typeof strictFn.call(5));     // Output: number

function sloppyFn() {
  return this;
}
console.log(typeof sloppyFn.call(5));     // Output: object

A plain call to sloppyFn() would return the global object, globalThis.

What to say in the interview

"A plain call has no receiver, so this is the global object in sloppy mode and undefined in strict mode. Classes and modules are strict by default, which is why a detached class method throws a TypeError instead of quietly using globals."

Common mistakes

  • Saying this is always the window. That is only true in sloppy mode, browser, plain calls.

#javascript#this#strict-mode

Related questions

Practise more JavaScript questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open JavaScript quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.