Annex C (informative) The Strict Mode of ECMAScript
The strict mode restriction and exceptions
-
implements,interface,let,package,private,protected,public,static, andyieldare reserved words withinstrict mode code . (11.6.2 ). -
A conforming implementation, when processing
strict mode code , must not extend, as described inB.1.1 , the syntax ofNumericLiteral to includeLegacyOctalIntegerLiteral , nor extend the syntax ofDecimalIntegerLiteral to includeNonOctalDecimalIntegerLiteral . -
A conforming implementation, when processing
strict mode code , may not extend the syntax ofEscapeSequence to includeLegacyOctalEscapeSequence as described inB.1.2 . -
Assignment to an undeclared identifier or otherwise unresolvable reference does not create a property in the
global object . When a simple assignment occurs withinstrict mode code , itsLeftHandSideExpression must not evaluate to an unresolvableReference . If it does aReferenceError exception is thrown (6.2.3.2 ). TheLeftHandSideExpression also may not be a reference to a data property with the attribute value {[[Writable]]:false }, to an accessor property with the attribute value {[[Set]]:undefined }, nor to a non-existent property of an object whose [[Extensible]] internal slot has the valuefalse . In these cases aTypeErrorexception is thrown (12.15 ). -
The identifier
evalorargumentsmay not appear as theLeftHandSideExpression of an Assignment operator (12.15 ) or of aUpdateExpression (12.4 ) or as theUnaryExpression operated upon by a Prefix Increment (12.4.6 ) or a Prefix Decrement (12.4.7 ) operator. -
Arguments objects for strict mode functions define non-configurable accessor properties named
"caller"and"callee"which throw aTypeError exception on access (9.2.7 ). -
Arguments objects for strict mode functions do not dynamically share their array indexed property values with the corresponding formal parameter bindings of their functions. (
9.4.4 ). -
For strict mode functions, if an arguments object is created the binding of the local identifier
argumentsto the arguments object is immutable and hence may not be the target of an assignment expression. (9.2.12 ). -
It is a
SyntaxError if theIdentifierName evalor theIdentifierName argumentsoccurs as aBindingIdentifier withinstrict mode code (12.1.1 ). -
Strict mode eval code cannot instantiate variables or functions in the variable environment of the caller to eval. Instead, a new variable environment is created and that environment is used for declaration binding instantiation for the eval code (
18.2.1 ). -
If
this is evaluated withinstrict mode code , then thethis value is not coerced to an object. Athis value ofnull orundefined is not converted to theglobal object and primitive values are not converted to wrapper objects. Thethis value passed via a function call (including calls made usingFunction.prototype.applyandFunction.prototype.call) do not coerce the passed this value to an object (9.2.1.2 ,19.2.3.1 ,19.2.3.3 ). -
When a
deleteoperator occurs withinstrict mode code , aSyntaxError is thrown if itsUnaryExpression is a direct reference to a variable, function argument, or function name (12.5.3.1 ). -
When a
deleteoperator occurs withinstrict mode code , aTypeError is thrown if the property to be deleted has the attribute { [[Configurable]]:false } (12.5.3.2 ). -
Strict mode code may not include aWithStatement . The occurrence of aWithStatement in such a context is aSyntaxError (13.11.1 ). -
It is a
SyntaxError if aTryStatement with aCatch occurs withinstrict mode code and theIdentifier of theCatch production isevalorarguments(13.15.1 ). -
It is a
SyntaxError if the sameBindingIdentifier appears more than once in theFormalParameters of a strict mode function. An attempt to create such a function using aFunctionorGeneratorconstructor is aSyntaxError (14.1.2 ,19.2.1.1.1 ). -
An implementation may not extend, beyond that defined in this specification, the meanings within strict mode functions of properties named
callerorargumentsof function instances. ECMAScript code may not create or modify properties with these names on function objects that correspond to strict mode functions (16.2 ).