Strict mode makes it easier to write secure and error free code in JavaScript.
As an example, in normal JavaScript, mistyping or undefined a variable name creates a new global variable and this will not return any error but In strict mode, this will throw an error.

if you are using normal JavaScript and you will not receive any error when assign a value without defined variable.
In strict mode, any assignment to a non-defined property, a getter-only property, a non-existing property, a non-existing variable, or a non-existing object, will throw an error.

use strict;
a = 5; // This will return an error

In normal JavaScript

//use strict;
x = 5; // This will not return an error

News Reporter

Leave a Reply

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