InterviewHubPRO
Section Overview
Q73

Question 73 of 521

Part 2: Promises, Callbacks, Async & Strict Mode (54 - 103)

14%
JavaScript Internals (521 Qs)•Part 2: Promises, Callbacks, Async & Strict Mode (54 - 103)

How do you declare strict mode

The strict mode is declared by adding "use strict"; to the beginning of a script or a function. If declared at the beginning of a script, it has global scope.

javascript
"use strict";
x = 3.14; // This will cause an error because x is not declared

and if you declare inside a function, it has local scope

javascript
x = 3.14; // This will not cause an error.
myFunction();

function myFunction() {
  "use strict";
  y = 3.14; // This will cause an error
}