JavaScript Strict Mode
المعرفة:: JavaScript
الحالة:: ملاحظة_مؤرشفة
المراجع:: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode, The Complete JavaScript Course 2022 From Zero to Expert
- 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") */
- 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
Last update :
August 14, 2023
Created : August 23, 2022
Created : August 23, 2022