DEV Community

Mary
Mary

Posted on

What does "use strict" mean in JavaScript?

The "use strict" in your JavaScript code turns on strict mode. (Or does nothing, in pre-fifth ECMAScript implementations). This directive applies to the scope in which it is specified.
Examples of using
// file: ok.js
"use strict"; // affects the whole file
alert ("ok");
(function () {
"use strict"; // valid only within the function
alert ("ok");
} ());

To learn why you need this mode in your coding, read the article to the end.

Top comments (0)