JavaScript Use Strict

"use strict"; Defines that JavaScript code should be executed in “strict mode” only i.e.don’t use undeclared variables.Strict mode makes it easier to write “secure” JavaScript.

Declaring Strict Mode:

Strict mode is declared by adding “use strict”; to the beginning of a JavaScript file, or a JavaScript function and it will have a global scope (all code will execute in strict mode). Declared inside a function, it has local scope (only the code inside the function is in strict mode).

Global declaration:

Local declaration:

Leave a Reply

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