This article ish5eduAgency officialHTML5 Trainingtutorials, the main introduction:JavaScript Intensive Tutorials--Strict mode
avascript Strict Mode (use strict) javascript Strict mode (Strict mode) is run under strict conditions. Use "use strict" instruction "use strict" instruction in JavaScript 1.8.5 (ECMASCRIPT5) New in . It is not a statement, but it is a literal expression that is ignored in the JavaScript old version. The purpose of the "use strict" is to specify that the code executes under strict conditions. You cannot use undeclared variables in strict mode. Strict mode restrictions do not allow undeclared variables: "Use strict";x = 3.14; // error (x undefined) The note object is also a variable. "Use strict";x = {p1:10, p2:20}; // error (x undefined) does not allow the deletion of variables or objects. "Use strict";var x = 3.14;delete x; // error not allowed to delete function. "Use strict"; function x (P1, P2) {}; delete x; // error Do not allow variable names: "USe strict "; function x (P1, P1) {}; // error is not allowed to use octal:" Use strict "; var x = 010; // Error not allowed escape character: "Use strict";var x = \010; // error not allowed to assign value to read-only attribute: "Use strict"; var obj = {};o Bject.defineproperty (obj, "x", {value:0, writable:false});obj.x = 3.14; // An error is not allowed to assign a property that is read using the Getter method "use Strict "; Var obj = {get x () {return 0} };obj.x = 3.14; // error not allowed to delete a property that is not allowed to be deleted: "Use strict";d elete Object.prototype; // error variable name cannot be used "eval" string: "Use strict"; var eval = 3.14; // error variable name cannot be used "arguments" string: "Use strict"; var arguments = 3.14; // error does not allow the use of the following statement: "Use strict";with (Math) {X = cos ( 2)}; // error due to some security reasons, the variable created in scope eval () cannot be called: "Use strict";eval ("var x = 2 ");alert (x);
Click to enter JS Intensive tutorial
This article is from the "11721999" blog, please be sure to keep this source http://11731999.blog.51cto.com/11721999/1860509
JavaScript Intensive Tutorial--Strict mode