Labs ICT
Pro Login

Strict Mode

Strict Mode — Writing Better JavaScript

Strict mode is a way to opt into a restricted variant of JavaScript. It catches common mistakes, throws errors on silent failures, and prevents potentially dangerous actions like creating global variables by accident.

Enable it by adding "use strict"; at the top of a file or function. Once enabled, there's no turning back — but that's a good thing.

"use strict";

// This would fail in strict mode
// x = 10; // ReferenceError

let y = 10;
console.log(y);

// Deleting a variable is not allowed
// delete y; // SyntaxError
Try it Yourself →

Other strict mode benefits: no duplicate parameter names, no this coercion to global, and more. Use strict mode in all new projects.