Interview Question

What is strict mode?

Strict mode removes or changes error-prone legacy behavior.

💡 Concept ✅ Quick Revision ⚡ JavaScript

Answer

Strict mode enables stricter ECMAScript semantics for a script or function body. • It rejects some silent errors and restricts legacy syntax. • In strict functions, an unbound this value remains undefined instead of becoming the global object. • ECMAScript modules and class bodies are strict automatically.

Example

Code
'use strict';
function showThis() { return this; }
console.log(showThis());
Output
undefined

Quick Revision

Strict mode removes or changes error-prone legacy behavior.