Language elements |
Limit |
Error |
Example |
variable |
Use variables but not declarations. |
script5042: variable not defined in strict mode |
javascript TestVar = 4; |
read-only attribute |
writes to the read-only property. |
script5045: No assignment to read-only properties in strict mode |
javascript var testobj = object.defineproperties ({}, {prop1: {value:10, Writable:false By default}, Prop2: {get:function () {}}}); testobj.prop1 = 20;
TESTOBJ.PROP2 = +; |
Non-extensible properties |
Adds an attribute to an object with the extensible property set to False. |
SCRIPT5046: Cannot create properties for non-extensible objects |
Javascriptvar testobj = new Object (); object.preventextensions (testobj); testobj.name = "Bob"; |
Delete |
Delete a variable, function, or parameter. Remove The property that has the configurable attribute set to False. |
SCRIPT1045: not allowed for < expressions > call Delete in strict mode |
Javascriptvar TestVar = 15;function TestFunc () {};d elete Testvar;delete testfunc;object.defineproperty (testobj, "TestVar", { Value:10, configurable:false });d elete Testobj.testvar; |
Repeating properties |
Defines a property more than once in an object literal. |
SCRIPT1046: A property is not allowed to have more than one definition in strict mode |
Javascriptvar testobj = { prop1:10, prop2:15, prop1:20}; |
Duplicate parameter name |
Use a parameter name more than once in a function. |
SCRIPT1038: Formal parameter name duplication is not allowed in strict mode |
Javascriptfunction TestFunc (param1, param1) { return 1;}; |
Future reserved Keywords |
Use future reserved keywords as variables or function names. |
SCRIPT1050: Cannot use future reserved words for identifiers. The identifier name is reserved in strict mode. |
-
implements
-
interface
-
package
-
private
-
protected
-
public
-
static
-
yield
|
Octal number |
Assigns octal values to numeric literals, or attempts to use escape for octal values. |
SCRIPT1039: Octal numeric parameters and escape characters are not allowed in strict mode |
Javascriptvar testoctal = 010;var Testescape = \010; |
This |
When the value of this is null or undefined, the value is not converted to a global object. |
|
javascript function TestFunc () {return this;} var TestVar = TestFunc (); testvar is the global object, but in strict mode the value is undefined." In non-strict mode, the value of the testvar is a global object, but in strict mode, the value is undefined. |
eval as an identifier" > as identifier of eval |
string" eval "cannot be used as an identifier (variable or function name, parameter name, etc.). |
|
javascript var eval = ten; |
statement or function declared in a block |
You cannot declare a function in a statement or block. |
script1047: In strict mode, a function declaration cannot be nested within a statement or block. They can only be displayed at the top level or directly in the function body. |
jscript var arr = [1, 2, 3, 4, 5];var index = null;for (index in arr) {function
MyFunc () {};} |
Variables declared within the Eval function |
If you declare a variable within the Eval function, you cannot use the variable outside of the function. |
SCRIPT1041: "eval" usage is not valid in strict mode |
javascript eval ("var TestVar = ten"); testvar =; eval function. " > Although indirect calculations are allowed, you still cannot use variables declared outside the eval function. javascript var indirecteval = Eval;indirecteval ("var testvar = 10;"); document.write (TestVar); |
arguments as an identifier" > as identifier of arguments |
string" Arguments "cannot be used as an identifier (variable or function name, parameter name, etc.). |
|
Arguments within a function |
You cannot change the value of a member of a local arguments object. |
|
Javascriptfunction Testargs (onearg) { arguments[0] = 20;}
In non-strict mode, you can change thearguments[0] to change the value of the onearg parameter so that onearg and arguments[0] have a value of 20. arguments[0] does not affect the value of Onearg, because the arguments object is merely a local copy. " In strict mode, changing the value of the arguments[0] does not affect the value of onearg because The arguments object is just a local copy. |
Arguments.callee |
Not allowed. |
|
Javascriptfunction (testint) { if (testint--= = 0) return; Arguments.callee (testint--);} |
With |
Not allowed. |
SCRIPT1037: "With" statement is not allowed in strict mode |
JavascriptWith (Math) { x = cos (3); y = tan (7);} |