1. Concept
1. Syntax becomes stricter
2. How to turn on strict mode
1. "use strict"
3. General restrictions
1. Variables declared without var cannot be used
2. Duplicate parameter names cannot be used! ! !
3. Previously, there could be no duplicate attribute names in strict mode, but after the update, it is allowed to do so!
4. Strict mode cannot use octal constants
5. In strict mode, eval has its own separate scope! !
4. Code details
// 1. Cannot use variables declared without var a = 10; //a is not defined(…) console.log(a); //2. You cannot use duplicate parameter names! ! ! //Duplicate parameter name not allowed in this context function test(a,a){}; test(); //3. Previously, there could be no duplicate attribute names in strict mode, but after the update, it was allowed to do so! var obj = { name : 'waxun', name: 'kaguo' }; //Object {name: "kaguo"} console.log(obj); //4. Strict mode cannot use octal constants // Octal literals are not allowed in strict mode. var b = 010; console.log(b); //5. In strict mode, eval has its own separate scope! ! //Note: If strict mode is not turned on, the variables in eval can be accessed eval('var a = 10;'); //a is not defined(…) console.log(a); //property 'prototype' of function Object() { [native code] }(…) //In non-strict mode, it cannot be deleted, but no error will be reported delete Object.prototype;