Advertisement
728x90
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
1"use strict";
2
3x = 3.14; // This will cause an error because x is not declaredand if you declare inside a function, it has local scope
javascript
1x = 3.14; // This will not cause an error.
2
3myFunction();
4
5function myFunction() {
6 "use strict";
7
8y = 3.14; // This will cause an error
9}Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 70
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
69of476