المعرفة:: JavaScript الحالة::مؤرشفة المراجع:: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode, The Complete JavaScript Course 2022 From Zero to Expert


// Whole-script strict mode syntax
"use strict";
var v = "Hi! I'm a strict mode script!";
  1. Eliminates some JavaScript silent errors by changing them to throw errors.
"use strict";
let mistypeVariable;
mistypeVarible = 17;
/* Assuming no global variable mistypeVarible exists, this line throws a ReferenceError due to the misspelling of "mistypeVariable" (lack of an "a") */
  1. Prohibits some syntax likely to be defined in future versions of ECMAScript. E.g. private, interface.
// Assignment to a non-writable global
var undefined = 5; // throws a TypeError
var Infinity = 5; // throws a TypeError