JavaScript Strict Mode

The strict mode in JavaScript is the usage of strict mode in JavaScript. It is defined as the following in the JavaScript code:

Not Allowed: Using an undeclared variable

The code executed in the strict mode can never have undeclared variables. Let us see an example:

Output

On pressing F12, the exact error is visible because we have used the strict mode and used a variable without declaring:
Strict Mode JavaScript Example

Not Allowed: Deleting a variable

If your JavaScript code is in strict mode, then you cannot delete the variable. Let us see an example:

Output

On pressing F12, the exact error is visible because we have used the strict mode and deleted a variable:

Strict Mode JavaScript

JavaScript - Hoisting
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading