Posted on Leave a comment

JavaScript Strict Mode: What it Does and Doesn’t Allow

In this tutorial, you will learn about the strict mode in JavaSript, the process of activating strict mode for a program or an individual function in JavaScript, and some typical actions that are forbidden by strict mode in JavaScript.

Activating JavaScript Strict mode

For activating Strict mode, you can add ‘use strict’; or “use strict”; at the beginning of the script.


‘use strict’;// or"use strict";

This statement should be the first statement in the script excluding comments as JavaScript just ignore them.

If there is any other statement before ‘use strict’; or “use strict”; then string mode will not activate.

Adding ‘use strict’; or “use strict”; at the beginning of the script has a global scope which makes all the code in that script executed in string mode.


"use strict";name = "John";console.log(name);


name = "John";

ReferenceError: name is not defined

Without Strict Mode:

name = "John";console.log(name);


Leave a Reply

Your email address will not be published. Required fields are marked *