Annex B (normative) Additional ECMAScript Features for Web Browsers
The ECMAScript language syntax and semantics defined in this annex are required when the ECMAScript host is a web browser. The content of this annex is normative but optional if the ECMAScript host is not a web browser.
This annex describes various legacy features and other characteristics of web browser based ECMAScript implementations. All of the language features and behaviours specified in this annex have one or more undesirable characteristics and in the absence of legacy usage would be removed from this specification. However, the usage of these features by large numbers of existing web pages means that web browsers must continue to support them. The specifications in this annex define the requirements for interoperable implementations of these legacy features.
These features are not considered part of the core ECMAScript language. Programmers should not use or assume the existence of these features and behaviours when writing new ECMAScript code. ECMAScript implementations are discouraged from implementing these features unless the implementation is part of a web browser or is required to run the same legacy ECMAScript code that web browsers encounter.
B.1 Additional Syntax
B.1.1 Numeric Literals
The syntax and semantics of
Syntax
B.1.1.1 Static Semantics
-
The MV of
is the MV ofLegacyOctalIntegerLiteral :: 0 OctalDigit OctalDigit . -
The MV of
is (the MV ofLegacyOctalIntegerLiteral :: LegacyOctalIntegerLiteral OctalDigit LegacyOctalIntegerLiteral times 8) plus the MV ofOctalDigit . -
The MV of
is the MV ofDecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral NonOctalDecimalIntegerLiteral . -
The MV of
is the MV ofNonOctalDecimalIntegerLiteral :: 0 NonOctalDigit NonOctalDigit . -
The MV of
is (the MV ofNonOctalDecimalIntegerLiteral :: LegacyOctalLikeDecimalIntegerLiteral NonOctalDigit LegacyOctalLikeDecimalIntegerLiteral times 10) plus the MV ofNonOctalDigit . -
The MV of
is (the MV ofNonOctalDecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral DecimalDigit NonOctalDecimalIntegerLiteral times 10) plus the MV ofDecimalDigit . -
The MV of
is the MV ofLegacyOctalLikeDecimalIntegerLiteral :: 0 OctalDigit OctalDigit . -
The MV of
is (the MV ofLegacyOctalLikeDecimalIntegerLiteral :: LegacyOctalLikeDecimalIntegerLiteral OctalDigit LegacyOctalLikeDecimalIntegerLiteral times 10) plus the MV ofOctalDigit . -
The MV of
is 8.NonOctalDigit :: 8 -
The MV of
is 9.NonOctalDigit :: 9
B.1.2 String Literals
The syntax and semantics of
Syntax
This definition of
B.1.2.1 Static Semantics
-
The SV of
is the SV of theEscapeSequence :: LegacyOctalEscapeSequence LegacyOctalEscapeSequence . -
The SV of
is the code unit whose value is the MV of theLegacyOctalEscapeSequence :: OctalDigit OctalDigit . -
The SV of
is the code unit whose value is (8 times the MV of theLegacyOctalEscapeSequence :: ZeroToThree OctalDigit ZeroToThree ) plus the MV of theOctalDigit . -
The SV of
is the code unit whose value is (8 times the MV of theLegacyOctalEscapeSequence :: FourToSeven OctalDigit FourToSeven ) plus the MV of theOctalDigit . -
The SV of
is the code unit whose value is (64 (that is, 82) times the MV of theLegacyOctalEscapeSequence :: ZeroToThree OctalDigit OctalDigit ZeroToThree ) plus (8 times the MV of the firstOctalDigit ) plus the MV of the secondOctalDigit . -
The MV of
is 0.ZeroToThree :: 0 -
The MV of
is 1.ZeroToThree :: 1 -
The MV of
is 2.ZeroToThree :: 2 -
The MV of
is 3.ZeroToThree :: 3 -
The MV of
is 4.FourToSeven :: 4 -
The MV of
is 5.FourToSeven :: 5 -
The MV of
is 6.FourToSeven :: 6 -
The MV of
is 7.FourToSeven :: 7
B.1.3 HTML-like Comments
The syntax and semantics of
Syntax
Similar to a
B.1.4 Regular Expressions Patterns
The syntax of
This alternative pattern grammar and semantics only changes the syntax and semantics of BMP patterns. The following grammar extensions include productions parameterized with the [U] parameter. However, none of these extensions change the syntax of Unicode patterns recognized when parsing with the [U] parameter present on the
Syntax
When the same left hand sides occurs with both [+U] and [~U] guards it is to control the disambiguation priority.
B.1.4.1 Static Semantics: Early Errors
The semantics of
- It is a Syntax Error if any source text matches this rule.
-
It is a Syntax Error if IsCharacterClass of the first
ClassAtom istrue or IsCharacterClass of the secondClassAtom istrue and this production has a [U] parameter.
-
It is a Syntax Error if IsCharacterClass of
ClassAtomNoDash istrue or IsCharacterClass ofClassAtom istrue and this production has a [U] parameter.
B.1.4.2 Static Semantics: IsCharacterClass
The semantics of
- Return
false .
B.1.4.3 Static Semantics: CharacterValue
The semantics of
- Return the code point value of U+005C (REVERSE SOLIDUS).
- Let ch be the code point matched by
ClassControlLetter . - Let i be ch's code point value.
- Return the remainder of dividing i by 32.
- Evaluate the SV of the
LegacyOctalEscapeSequence (seeB.1.2 ) to obtain a code unit cu. - Return the numeric value of cu.
B.1.4.4 Pattern Semantics
The semantics of
Within
Term (
The production
The production
The production
Assertion (
The production
- Evaluate
QuantifiableAssertion to obtain a Matcher m. - Return m.
Assertion (
Atom (
The production
- Let A be the CharSet containing the single character
\U+005C (REVERSE SOLIDUS). - Call
CharacterSetMatcher (A,false ) and return its Matcher result.
The production
- Let ch be the character represented by
ExtendedPatternCharacter . - Let A be a one-element CharSet containing the character ch.
- Call
CharacterSetMatcher (A,false ) and return its Matcher result.
CharacterEscape (
The production
- Let cv be the CharacterValue of this
CharacterEscape . - Return the character whose character value is cv.
NonemptyClassRanges (
The production
- Evaluate the first
ClassAtom to obtain a CharSet A. - Evaluate the second
ClassAtom to obtain a CharSet B. - Evaluate
ClassRanges to obtain a CharSet C. - Call
CharacterRangeOrUnion (A, B) and let D be the resulting CharSet. - Return the union of CharSets D and C.
NonemptyClassRangesNoDash (
The production
- Evaluate
ClassAtomNoDash to obtain a CharSet A. - Evaluate
ClassAtom to obtain a CharSet B. - Evaluate
ClassRanges to obtain a CharSet C. - Call
CharacterRangeOrUnion (A, B) and let D be the resulting CharSet. - Return the union of CharSets D and C.
ClassEscape (
The production
- Let cv be the CharacterValue of this
ClassEscape . - Let c be the character whose character value is cv.
- Return the CharSet containing the single character c.
ClassAtomNoDash (
The production
- Return the CharSet containing the single character
\U+005C (REVERSE SOLIDUS).
\c within a character class where it is not followed by an acceptable control character.B.1.4.4.1 Runtime Semantics: CharacterRangeOrUnion ( A, B )
The abstract operation CharacterRangeOrUnion takes two CharSet parameters A and B and performs the following steps:
- If Unicode is
false , then- If A does not contain exactly one character or B does not contain exactly one character, then
- Let C be the CharSet containing the single character
-U+002D (HYPHEN-MINUS). - Return the union of CharSets A, B and C.
- Let C be the CharSet containing the single character
- If A does not contain exactly one character or B does not contain exactly one character, then
- Return
CharacterRange (A, B).
B.2 Additional Built-in Properties
When the ECMAScript host is a web browser the following additional properties of the standard built-in objects are defined.
B.2.1 Additional Properties of the Global Object
The entries in
| Intrinsic Name | Global Name | ECMAScript Language Association |
|---|---|---|
|
|
escape
|
The escape function ( |
|
|
unescape
|
The unescape function ( |
B.2.1.1 escape ( string )
The escape function is a property of the
For those code units being replaced whose value is 0x00FF or less, a two-digit escape sequence of the form %xx is used. For those characters being replaced whose code unit value is greater than 0x00FF, a four-digit escape sequence of the form %uxxxx is used.
The escape function is the escape function is called with one argument string, the following steps are taken:
Set string to ?ToString (string).- Let length be the number of code units in string.
- Let R be the empty string.
- Let k be 0.
- Repeat, while k < length,
- Let char be the code unit (represented as a 16-bit unsigned integer) at index k within string.
- If char is one of the code units in
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./", then- Let S be the String value containing the single code unit char.
- Else if char ≥ 256, then
- Let n be the numeric value of char.
- Let S be the
string-concatenation of:"%u"- the String representation of n, formatted as a four-digit uppercase hexadecimal number, padded to the left with zeroes if necessary
- Else char < 256,
- Let n be the numeric value of char.
- Let S be the
string-concatenation of:"%"- the String representation of n, formatted as a two-digit uppercase hexadecimal number, padded to the left with a zero if necessary
Set R to thestring-concatenation of the previous value of R and S.- Increase k by 1.
- Return R.
The encoding is partly based on the encoding described in RFC 1738, but the entire encoding specified in this standard is described above without regard to the contents of RFC 1738. This encoding does not reflect changes to RFC 1738 made by RFC 3986.
B.2.1.2 unescape ( string )
The unescape function is a property of the escape function is replaced with the code unit that it represents.
The unescape function is the unescape function is called with one argument string, the following steps are taken:
Set string to ?ToString (string).- Let length be the number of code units in string.
- Let R be the empty String.
- Let k be 0.
- Repeat, while k ≠ length
- Let c be the code unit at index k within string.
- If c is the code unit 0x0025 (PERCENT SIGN), then
- If k ≤ length - 6 and the code unit at index k + 1 within string is the code unit 0x0075 (LATIN SMALL LETTER U) and the four code units at indices k + 2, k + 3, k + 4, and k + 5 within string are all hexadecimal digits, then
Set c to the code unit whose value is the integer represented by the four hexadecimal digits at indices k + 2, k + 3, k + 4, and k + 5 within string.- Increase k by 5.
- Else if k ≤ length - 3 and the two code units at indices k + 1 and k + 2 within string are both hexadecimal digits, then
Set c to the code unit whose value is the integer represented by two zeroes plus the two hexadecimal digits at indices k + 1 and k + 2 within string.- Increase k by 2.
- If k ≤ length - 6 and the code unit at index k + 1 within string is the code unit 0x0075 (LATIN SMALL LETTER U) and the four code units at indices k + 2, k + 3, k + 4, and k + 5 within string are all hexadecimal digits, then
Set R to thestring-concatenation of the previous value of R and c.- Increase k by 1.
- Return R.
B.2.2 Additional Properties of the Object.prototype Object
B.2.2.1 Object.prototype.__proto__
Object.prototype.__proto__ is an
B.2.2.1.1 get Object.prototype.__proto__
The value of the [[Get]] attribute is a built-in function that requires no arguments. It performs the following steps:
- Let O be ?
ToObject (this value). - Return ? O.[[GetPrototypeOf]]().
B.2.2.1.2 set Object.prototype.__proto__
The value of the [[Set]] attribute is a built-in function that takes an argument proto. It performs the following steps:
- Let O be ?
RequireObjectCoercible (this value). - If
Type (proto) is neither Object nor Null, returnundefined . - If
Type (O) is not Object, returnundefined . - Let status be ? O.[[SetPrototypeOf]](proto).
- If status is
false , throw aTypeError exception. - Return
undefined .
B.2.2.2 Object.prototype.__defineGetter__ ( P, getter )
When the __defineGetter__ method is called with arguments P and getter, the following steps are taken:
- Let O be ?
ToObject (this value). - If
IsCallable (getter) isfalse , throw aTypeError exception. - Let desc be PropertyDescriptor { [[Get]]: getter, [[Enumerable]]:
true , [[Configurable]]:true }. - Let key be ?
ToPropertyKey (P). - Perform ?
DefinePropertyOrThrow (O, key, desc). - Return
undefined .
B.2.2.3 Object.prototype.__defineSetter__ ( P, setter )
When the __defineSetter__ method is called with arguments P and setter, the following steps are taken:
- Let O be ?
ToObject (this value). - If
IsCallable (setter) isfalse , throw aTypeError exception. - Let desc be PropertyDescriptor { [[Set]]: setter, [[Enumerable]]:
true , [[Configurable]]:true }. - Let key be ?
ToPropertyKey (P). - Perform ?
DefinePropertyOrThrow (O, key, desc). - Return
undefined .
B.2.2.4 Object.prototype.__lookupGetter__ ( P )
When the __lookupGetter__ method is called with argument P, the following steps are taken:
- Let O be ?
ToObject (this value). - Let key be ?
ToPropertyKey (P). - Repeat,
- Let desc be ? O.[[GetOwnProperty]](key).
- If desc is not
undefined , then- If
IsAccessorDescriptor (desc) istrue , return desc.[[Get]]. - Return
undefined .
- If
Set O to ? O.[[GetPrototypeOf]]().- If O is
null , returnundefined .
B.2.2.5 Object.prototype.__lookupSetter__ ( P )
When the __lookupSetter__ method is called with argument P, the following steps are taken:
- Let O be ?
ToObject (this value). - Let key be ?
ToPropertyKey (P). - Repeat,
- Let desc be ? O.[[GetOwnProperty]](key).
- If desc is not
undefined , then- If
IsAccessorDescriptor (desc) istrue , return desc.[[Set]]. - Return
undefined .
- If
Set O to ? O.[[GetPrototypeOf]]().- If O is
null , returnundefined .
B.2.3 Additional Properties of the String.prototype Object
B.2.3.1 String.prototype.substr ( start, length )
The substr method takes two arguments, start and length, and returns a substring of the result of converting the
- Let O be ?
RequireObjectCoercible (this value). - Let S be ?
ToString (O). - Let intStart be ?
ToInteger (start). - If length is
undefined , let end be+∞ ; otherwise let end be ?ToInteger (length). - Let size be the number of code units in S.
- If intStart < 0, set intStart to
max (size + intStart, 0). - Let resultLength be
min (max (end, 0), size - intStart). - If resultLength ≤ 0, return the empty String
"". - Return the String value containing resultLength consecutive code units from S beginning with the code unit at index intStart.
The substr function is intentionally generic; it does not require that its
B.2.3.2 String.prototype.anchor ( name )
When the anchor method is called with argument name, the following steps are taken:
- Let S be the
this value. - Return ?
CreateHTML (S,"a","name", name).
B.2.3.2.1 Runtime Semantics: CreateHTML ( string, tag, attribute, value )
The abstract operation CreateHTML is called with arguments string, tag, attribute, and value. The arguments tag and attribute must be String values. The following steps are taken:
- Let str be ?
RequireObjectCoercible (string). - Let S be ?
ToString (str). - Let p1 be the
string-concatenation of"<"and tag. - If attribute is not the empty String, then
- Let V be ?
ToString (value). - Let escapedV be the String value that is the same as V except that each occurrence of the code unit 0x0022 (QUOTATION MARK) in V has been replaced with the six code unit sequence
""". Set p1 to thestring-concatenation of:- p1
- the code unit 0x0020 (SPACE)
- attribute
- the code unit 0x003D (EQUALS SIGN)
- the code unit 0x0022 (QUOTATION MARK)
- escapedV
- the code unit 0x0022 (QUOTATION MARK)
- Let V be ?
- Let p2 be the
string-concatenation of p1 and">". - Let p3 be the
string-concatenation of p2 and S. - Let p4 be the
string-concatenation of p3,"</", tag, and">". - Return p4.
B.2.3.3 String.prototype.big ( )
When the big method is called with no arguments, the following steps are taken:
- Let S be the
this value. - Return ?
CreateHTML (S,"big","","").
B.2.3.4 String.prototype.blink ( )
When the blink method is called with no arguments, the following steps are taken:
- Let S be the
this value. - Return ?
CreateHTML (S,"blink","","").
B.2.3.5 String.prototype.bold ( )
When the bold method is called with no arguments, the following steps are taken:
- Let S be the
this value. - Return ?
CreateHTML (S,"b","","").
B.2.3.6 String.prototype.fixed ( )
When the fixed method is called with no arguments, the following steps are taken:
- Let S be the
this value. - Return ?
CreateHTML (S,"tt","","").
B.2.3.7 String.prototype.fontcolor ( color )
When the fontcolor method is called with argument color, the following steps are taken:
- Let S be the
this value. - Return ?
CreateHTML (S,"font","color", color).
B.2.3.8 String.prototype.fontsize ( size )
When the fontsize method is called with argument size, the following steps are taken:
- Let S be the
this value. - Return ?
CreateHTML (S,"font","size", size).
B.2.3.9 String.prototype.italics ( )
When the italics method is called with no arguments, the following steps are taken:
- Let S be the
this value. - Return ?
CreateHTML (S,"i","","").
B.2.3.10 String.prototype.link ( url )
When the link method is called with argument url, the following steps are taken:
- Let S be the
this value. - Return ?
CreateHTML (S,"a","href", url).
B.2.3.11 String.prototype.small ( )
When the small method is called with no arguments, the following steps are taken:
- Let S be the
this value. - Return ?
CreateHTML (S,"small","","").
B.2.3.12 String.prototype.strike ( )
When the strike method is called with no arguments, the following steps are taken:
- Let S be the
this value. - Return ?
CreateHTML (S,"strike","","").
B.2.3.13 String.prototype.sub ( )
When the sub method is called with no arguments, the following steps are taken:
- Let S be the
this value. - Return ?
CreateHTML (S,"sub","","").
B.2.3.14 String.prototype.sup ( )
When the sup method is called with no arguments, the following steps are taken:
- Let S be the
this value. - Return ?
CreateHTML (S,"sup","","").
B.2.3.15 String.prototype.trimLeft ( )
The property trimStart is preferred. The trimLeft property is provided principally for compatibility with old code. It is recommended that the trimStart property be used in new ECMAScript code.
The initial value of the trimLeft property is the same String.prototype.trimStart property.
B.2.3.16 String.prototype.trimRight ( )
The property trimEnd is preferred. The trimRight property is provided principally for compatibility with old code. It is recommended that the trimEnd property be used in new ECMAScript code.
The initial value of the trimRight property is the same String.prototype.trimEnd property.
B.2.4 Additional Properties of the Date.prototype Object
B.2.4.1 Date.prototype.getYear ( )
The getFullYear method is preferred for nearly all purposes, because it avoids the “year 2000 problem.”
When the getYear method is called with no arguments, the following steps are taken:
- Let t be ?
thisTimeValue (this value). - If t is
NaN , returnNaN . - Return
YearFromTime (LocalTime (t)) - 1900.
B.2.4.2 Date.prototype.setYear ( year )
The setFullYear method is preferred for nearly all purposes, because it avoids the “year 2000 problem.”
When the setYear method is called with one argument year, the following steps are taken:
- Let t be ?
thisTimeValue (this value). - If t is
NaN , set t to+0 ; otherwise, set t toLocalTime (t). - Let y be ?
ToNumber (year). - If y is
NaN , thenSet the [[DateValue]] internal slot ofthis Date object toNaN .- Return
NaN .
- Let yi be !
ToInteger (y). - If 0 ≤ yi ≤ 99, let yyyy be yi + 1900.
- Else, let yyyy be y.
- Let d be
MakeDay (yyyy,MonthFromTime (t), DateFromTime(t)). - Let date be
UTC (MakeDate (d,TimeWithinDay (t))). Set the [[DateValue]] internal slot ofthis Date object toTimeClip (date).- Return the value of the [[DateValue]] internal slot of
this Date object .
B.2.4.3 Date.prototype.toGMTString ( )
The property toUTCString is preferred. The toGMTString property is provided principally for compatibility with old code. It is recommended that the toUTCString property be used in new ECMAScript code.
The Date.prototype.toGMTString is the same Date.prototype.toUTCString.
B.2.5 Additional Properties of the RegExp.prototype Object
B.2.5.1 RegExp.prototype.compile ( pattern, flags )
When the compile method is called with arguments pattern and flags, the following steps are taken:
- Let O be the
this value. - If
Type (O) is not Object orType (O) is Object and O does not have a [[RegExpMatcher]] internal slot, then- Throw a
TypeError exception.
- Throw a
- If
Type (pattern) is Object and pattern has a [[RegExpMatcher]] internal slot, then- If flags is not
undefined , throw aTypeError exception. - Let P be pattern.[[OriginalSource]].
- Let F be pattern.[[OriginalFlags]].
- If flags is not
- Else,
- Let P be pattern.
- Let F be flags.
- Return ?
RegExpInitialize (O, P, F).
The compile method completely reinitializes the
B.3 Other Additional Features
B.3.1 __proto__ Property Names in Object Initializers
The following Early Error rule is added to those in
-
It is a Syntax Error if PropertyNameList of
PropertyDefinitionList contains any duplicate entries for"__proto__"and at least two of those entries were obtained from productions of the form .PropertyDefinition : PropertyName : AssignmentExpression
The
In
is replaced with the following definition:
- Let propKey be the result of evaluating
PropertyName . ReturnIfAbrupt (propKey).- If propKey is the String value
"__proto__"and if IsComputedPropertyKey(PropertyName ) isfalse , then- Let isProtoSetter be
true .
- Let isProtoSetter be
- Else,
- Let isProtoSetter be
false .
- Let isProtoSetter be
- If
IsAnonymousFunctionDefinition (AssignmentExpression ) istrue and isProtoSetter isfalse , then- Let propValue be the result of performing NamedEvaluation for
AssignmentExpression with argument propKey.
- Let propValue be the result of performing NamedEvaluation for
- Else,
- Let exprValueRef be the result of evaluating
AssignmentExpression . - Let propValue be ?
GetValue (exprValueRef).
- Let exprValueRef be the result of evaluating
- If isProtoSetter is
true , then- If
Type (propValue) is either Object or Null, then- Return object.[[SetPrototypeOf]](propValue).
- Return
NormalCompletion (empty ).
- If
Assert : enumerable istrue .Assert : object is an ordinary, extensible object with no non-configurable properties.- Return !
CreateDataPropertyOrThrow (object, propKey, propValue).
B.3.2 Labelled Function Declarations
Prior to ECMAScript 2015, the specification of
- It is a Syntax Error if any strict mode source code matches this rule.
The
B.3.3 Block-Level Function Declarations Web Legacy Compatibility Semantics
Prior to ECMAScript 2015, the ECMAScript specification did not define the occurrence of a
-
A function is declared and only referenced within a single block
-
One or more
FunctionDeclaration s whoseBindingIdentifier is the name f occur within the function code of an enclosing function g and that declaration is nested within aBlock . -
No other declaration of f that is not a
vardeclaration occurs within the function code of g -
All occurrences of f as an
IdentifierReference are within theStatementList of theBlock containing the declaration of f.
-
One or more
-
A function is declared and possibly used within a single
Block but also referenced by an inner function definition that is not contained within that sameBlock .-
One or more
FunctionDeclaration s whoseBindingIdentifier is the name f occur within the function code of an enclosing function g and that declaration is nested within aBlock . -
No other declaration of f that is not a
vardeclaration occurs within the function code of g -
There may be occurrences of f as an
IdentifierReference within theStatementList of theBlock containing the declaration of f. -
There is at least one occurrence of f as an
IdentifierReference within another function h that is nested within g and no other declaration of f shadows the references to f from within h. - All invocations of h occur after the declaration of f has been evaluated.
-
One or more
-
A function is declared and possibly used within a single block but also referenced within subsequent blocks.
-
One or more
FunctionDeclaration whoseBindingIdentifier is the name f occur within the function code of an enclosing function g and that declaration is nested within aBlock . -
No other declaration of f that is not a
vardeclaration occurs within the function code of g -
There may be occurrences of f as an
IdentifierReference within theStatementList of theBlock containing the declaration of f. -
There is at least one occurrence of f as an
IdentifierReference within the function code of g that lexically follows theBlock containing the declaration of f.
-
One or more
The first use case is interoperable with the semantics of
ECMAScript 2015 interoperability for the second and third use cases requires the following extensions to the clause
If an ECMAScript implementation has a mechanism for reporting diagnostic warning messages, a warning should be produced when code contains a
B.3.3.1 Changes to FunctionDeclarationInstantiation
During
- If strict is
false , then- For each
FunctionDeclaration f that is directly contained in theStatementList of aBlock ,CaseClause , orDefaultClause , do- Let F be StringValue of the
BindingIdentifier ofFunctionDeclaration f. - If replacing the
FunctionDeclaration f with aVariableStatement that has F as aBindingIdentifier would not produce any Early Errors for func and F is not an element of parameterNames, then- NOTE: A var binding for F is only instantiated here if it is neither a VarDeclaredName, the name of a formal parameter, or another
FunctionDeclaration . - If initializedBindings does not contain F and F is not
"arguments", then- Perform ! varEnvRec.CreateMutableBinding(F,
false ). - Perform varEnvRec.InitializeBinding(F,
undefined ). - Append F to instantiatedVarNames.
- Perform ! varEnvRec.CreateMutableBinding(F,
- When the
FunctionDeclaration f is evaluated, perform the following steps in place of theFunctionDeclaration Evaluation algorithm provided in14.1.22 :- Let fenv be the
running execution context 's VariableEnvironment. - Let fenvRec be fenv's
EnvironmentRecord . - Let benv be the
running execution context 's LexicalEnvironment. - Let benvRec be benv's
EnvironmentRecord . - Let fobj be ! benvRec.GetBindingValue(F,
false ). - Perform ! fenvRec.SetMutableBinding(F, fobj,
false ). - Return
NormalCompletion (empty ).
- Let fenv be the
- NOTE: A var binding for F is only instantiated here if it is neither a VarDeclaredName, the name of a formal parameter, or another
- Let F be StringValue of the
- For each
B.3.3.2 Changes to GlobalDeclarationInstantiation
During
- Let strict be IsStrict of script.
- If strict is
false , then- Let declaredFunctionOrVarNames be a new empty
List . - Append to declaredFunctionOrVarNames the elements of declaredFunctionNames.
- Append to declaredFunctionOrVarNames the elements of declaredVarNames.
- For each
FunctionDeclaration f that is directly contained in theStatementList of aBlock ,CaseClause , orDefaultClause Contained within script, do- Let F be StringValue of the
BindingIdentifier ofFunctionDeclaration f. - If replacing the
FunctionDeclaration f with aVariableStatement that has F as aBindingIdentifier would not produce any Early Errors for script, then- If envRec.HasLexicalDeclaration(F) is
false , then- Let fnDefinable be ? envRec.CanDeclareGlobalVar(F).
- If fnDefinable is
true , then- NOTE: A var binding for F is only instantiated here if it is neither a VarDeclaredName nor the name of another
FunctionDeclaration . - If declaredFunctionOrVarNames does not contain F, then
- Perform ? envRec.CreateGlobalVarBinding(F,
false ). - Append F to declaredFunctionOrVarNames.
- Perform ? envRec.CreateGlobalVarBinding(F,
- When the
FunctionDeclaration f is evaluated, perform the following steps in place of theFunctionDeclaration Evaluation algorithm provided in14.1.22 :- Let genv be the
running execution context 's VariableEnvironment. - Let genvRec be genv's
EnvironmentRecord . - Let benv be the
running execution context 's LexicalEnvironment. - Let benvRec be benv's
EnvironmentRecord . - Let fobj be ! benvRec.GetBindingValue(F,
false ). - Perform ? genvRec.SetMutableBinding(F, fobj,
false ). - Return
NormalCompletion (empty ).
- Let genv be the
- NOTE: A var binding for F is only instantiated here if it is neither a VarDeclaredName nor the name of another
- If envRec.HasLexicalDeclaration(F) is
- Let F be StringValue of the
- Let declaredFunctionOrVarNames be a new empty
B.3.3.3 Changes to EvalDeclarationInstantiation
During
- If strict is
false , then- Let declaredFunctionOrVarNames be a new empty
List . - Append to declaredFunctionOrVarNames the elements of declaredFunctionNames.
- Append to declaredFunctionOrVarNames the elements of declaredVarNames.
- For each
FunctionDeclaration f that is directly contained in theStatementList of aBlock ,CaseClause , orDefaultClause Contained within body, do- Let F be StringValue of the
BindingIdentifier ofFunctionDeclaration f. - If replacing the
FunctionDeclaration f with aVariableStatement that has F as aBindingIdentifier would not produce any Early Errors for body, then- Let bindingExists be
false . - Let thisLex be lexEnv.
Assert : The following loop will terminate.- Repeat, while thisLex is not the same as varEnv,
- Let thisEnvRec be thisLex's
EnvironmentRecord . - If thisEnvRec is not an object
Environment Record , then- If thisEnvRec.HasBinding(F) is
true , then- Let bindingExists be
true .
- Let bindingExists be
- If thisEnvRec.HasBinding(F) is
Set thisLex to thisLex's outer environment reference.
- Let thisEnvRec be thisLex's
- If bindingExists is
false and varEnvRec is a globalEnvironment Record , then- If varEnvRec.HasLexicalDeclaration(F) is
false , then- Let fnDefinable be ? varEnvRec.CanDeclareGlobalVar(F).
- Else,
- Let fnDefinable be
false .
- Let fnDefinable be
- If varEnvRec.HasLexicalDeclaration(F) is
- Else,
- Let fnDefinable be
true .
- Let fnDefinable be
- If bindingExists is
false and fnDefinable istrue , then- If declaredFunctionOrVarNames does not contain F, then
- If varEnvRec is a global
Environment Record , then- Perform ? varEnvRec.CreateGlobalVarBinding(F,
true ).
- Perform ? varEnvRec.CreateGlobalVarBinding(F,
- Else,
- Let bindingExists be varEnvRec.HasBinding(F).
- If bindingExists is
false , then- Perform ! varEnvRec.CreateMutableBinding(F,
true ). - Perform ! varEnvRec.InitializeBinding(F,
undefined ).
- Perform ! varEnvRec.CreateMutableBinding(F,
- Append F to declaredFunctionOrVarNames.
- If varEnvRec is a global
- When the
FunctionDeclaration f is evaluated, perform the following steps in place of theFunctionDeclaration Evaluation algorithm provided in14.1.22 :- Let genv be the
running execution context 's VariableEnvironment. - Let genvRec be genv's
EnvironmentRecord . - Let benv be the
running execution context 's LexicalEnvironment. - Let benvRec be benv's
EnvironmentRecord . - Let fobj be ! benvRec.GetBindingValue(F,
false ). - Perform ? genvRec.SetMutableBinding(F, fobj,
false ). - Return
NormalCompletion (empty ).
- Let genv be the
- If declaredFunctionOrVarNames does not contain F, then
- Let bindingExists be
- Let F be StringValue of the
- Let declaredFunctionOrVarNames be a new empty
B.3.3.4 Changes to Block Static Semantics: Early Errors
For web browser compatibility, that rule is modified with the addition of the highlighted text:
-
It is a Syntax Error if the LexicallyDeclaredNames of
StatementList contains any duplicate entries, unless the source code matching this production is notstrict mode code and the duplicate entries are only bound by FunctionDeclarations.
B.3.3.5 Changes to switch Statement Static Semantics: Early Errors
For web browser compatibility, that rule is modified with the addition of the highlighted text:
-
It is a Syntax Error if the LexicallyDeclaredNames of
CaseBlock contains any duplicate entries, unless the source code matching this production is notstrict mode code and the duplicate entries are only bound by FunctionDeclarations.
B.3.3.6 Changes to BlockDeclarationInstantiation
During
- If envRec.HasBinding(dn) is
false , then- Perform ! envRec.CreateMutableBinding(dn,
false ).
- Perform ! envRec.CreateMutableBinding(dn,
During
- If envRec.HasBinding(fn) is
false , then- Perform envRec.InitializeBinding(fn, fo).
- Else,
Assert : d is aFunctionDeclaration .- Perform envRec.SetMutableBinding(fn, fo,
false ).
B.3.4 FunctionDeclarations in IfStatement Statement Clauses
The following augments the
This production only applies when parsing
B.3.5 VariableStatements in Catch Blocks
The content of subclause
-
It is a Syntax Error if BoundNames of
CatchParameter contains any duplicate elements. -
It is a Syntax Error if any element of the BoundNames of
CatchParameter also occurs in the LexicallyDeclaredNames ofBlock . -
It is a Syntax Error if any element of the BoundNames of
CatchParameter also occurs in the VarDeclaredNames ofBlock unlessCatchParameter is .CatchParameter : BindingIdentifier
The var declarations that bind a name that is also bound by the var declarations will assign to the corresponding catch parameter rather than the var binding.
This modified behaviour also applies to var and function declarations introduced by
Step 5.d.ii.2.a.i is replaced by:
- If thisEnvRec is not the
Environment Record for aCatch clause, throw aSyntaxError exception.
Step 9.d.ii.4.b.i.i is replaced by:
- If thisEnvRec is not the
Environment Record for aCatch clause, let bindingExists betrue .
B.3.6 Initializers in ForIn Statement Heads
The following augments the
This production only applies when parsing
The
- Return ContainsDuplicateLabels of
Statement with argument labelSet.
The
- Return ContainsUndefinedBreakTarget of
Statement with argument labelSet.
The
- Return ContainsUndefinedContinueTarget of
Statement with arguments iterationSet and « ».
The
- Return
false .
The
- Let names be the BoundNames of
BindingIdentifier . - Append to names the elements of the VarDeclaredNames of
Statement . - Return names.
The
- Let declarations be a
List containingBindingIdentifier . - Append to declarations the elements of the VarScopedDeclarations of
Statement . - Return declarations.
The
- Let bindingId be StringValue of
BindingIdentifier . - Let lhs be ?
ResolveBinding (bindingId). - If
IsAnonymousFunctionDefinition (Initializer ) istrue , then- Let value be the result of performing NamedEvaluation for
Initializer with argument bindingId.
- Let value be the result of performing NamedEvaluation for
- Else,
- Let rhs be the result of evaluating
Initializer . - Let value be ?
GetValue (rhs).
- Let rhs be the result of evaluating
- Perform ?
PutValue (lhs, value). - Let keyResult be ?
ForIn/OfHeadEvaluation (« »,Expression ,enumerate ). - Return ?
ForIn/OfBodyEvaluation (BindingIdentifier ,Statement , keyResult,enumerate ,varBinding , labelSet).
B.3.7 The [[IsHTMLDDA]] Internal Slot
An [[IsHTMLDDA]] internal slot may exist on implementation-defined objects. Objects with an [[IsHTMLDDA]] internal slot behave like typeof operator
Objects with an [[IsHTMLDDA]] internal slot are never created by this specification. However, the document.all object in web browsers is a host-created document.all.
B.3.7.1 Changes to ToBoolean
B.3.7.2 Changes to Abstract Equality Comparison
The following steps are inserted after step 3 of the