In which environment can Strict Mode be worked?
Strict mode was introduced in ECMAScript 5 (ES5) and continues to be supported in all modern browsers and JavaScript environments.
※Alternatively, you can enable strict mode for an individual JavaScript file by using ECMAScript modules, which are automatically in strict mode by default.
What can Strict Mode do?
- Converting mistakes into errors
- Simplifying scope management
- Making eval and arguments simpler
- "Securing" JavaScript
- Future-proofing JavaScript
Usage of Strict Mode
It's very simple!
If you want to stict your javascript code, add just 'use strict' before the statement that you want to strict.
.js
"use strict";
let mistypeVariable;
// Assuming no global variable mistypeVarible exists
// this line throws a ReferenceError due to the
// misspelling of "mistypeVariable" (lack of an "a")
mistypeVarible = 17;