B.2 Additional Built-in Properties
When the ECMAScript
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 )
This function is a property of the
When replacing a code unit of numeric value less than or equal to 0x00FF, a two-digit escape sequence of the form %xx
is used. When replacing a code unit of numeric value strictly greater than 0x00FF, a four-digit escape sequence of the form %uxxxx
is used.
It is the %escape% intrinsic object.
It performs the following steps when called:
- Set string to ?
ToString (string). - Let len be the length of string.
- Let R be the empty String.
- Let unescapedSet be the
string-concatenation ofthe ASCII word characters and"@*+-./" . - Let k be 0.
- Repeat, while k < len,
- Let C be the code unit at index k within string.
- If unescapedSet contains C, then
- Let S be C.
- Else,
- Let n be the numeric value of C.
- If n < 256, then
- Let hex be the String representation of n, formatted as an uppercase hexadecimal number.
- Let S be the
string-concatenation of"%" andStringPad (hex, 2,"0" ,start ).
- Else,
- Let hex be the String representation of n, formatted as an uppercase hexadecimal number.
- Let S be the
string-concatenation of"%u" andStringPad (hex, 4,"0" ,start ).
- Set R to the
string-concatenation of R and S. - Set k to k + 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 )
This function is a property of the escape
function is replaced with the code unit that it represents.
It is the %unescape% intrinsic object.
It performs the following steps when called:
- Set string to ?
ToString (string). - Let len be the length of string.
- Let R be the empty String.
- Let k be 0.
- Repeat, while k < len,
- Let C be the code unit at index k within string.
- If C is the code unit 0x0025 (PERCENT SIGN), then
- Let hexDigits be the empty String.
- Let optionalAdvance be 0.
- If k + 5 < len and the code unit at index k + 1 within string is the code unit 0x0075 (LATIN SMALL LETTER U), then
- Set hexDigits to the
substring of string from k + 2 to k + 6. - Set optionalAdvance to 5.
- Set hexDigits to the
- Else if k + 3 ≤ len, then
- Set hexDigits to the
substring of string from k + 1 to k + 3. - Set optionalAdvance to 2.
- Set hexDigits to the
- Let parseResult be
ParseText (StringToCodePoints (hexDigits),HexDigits ).[~Sep] - If parseResult is a
Parse Node , then- Let n be the MV of parseResult.
- Set C to the code unit whose numeric value is n.
- Set k to k + optionalAdvance.
- Set R to the
string-concatenation of R and C. - Set k to k + 1.
- Return R.
B.2.2 Additional Properties of the String.prototype Object
B.2.2.1 String.prototype.substr ( start, length )
This method returns a
It performs the following steps when called:
- Let O be ?
RequireObjectCoercible (this value). - Let S be ?
ToString (O). - Let size be the length of S.
- Let intStart be ?
ToIntegerOrInfinity (start). - If intStart = -∞, set intStart to 0.
- Else if intStart < 0, set intStart to
max (size + intStart, 0). - Else, set intStart to
min (intStart, size). - If length is
undefined , let intLength be size; otherwise let intLength be ?ToIntegerOrInfinity (length). - Set intLength to the result of
clamping intLength between 0 and size. - Let intEnd be
min (intStart + intLength, size). - Return the
substring of S from intStart to intEnd.
This method is intentionally generic; it does not require that its
B.2.2.2 String.prototype.anchor ( name )
This method performs the following steps when called:
- Let S be the
this value. - Return ?
CreateHTML (S,"a" ,"name" , name).
B.2.2.2.1 CreateHTML ( string, tag, attribute, value )
The abstract operation CreateHTML takes arguments string (an
- 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 the
string-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.2.3 String.prototype.big ( )
This method performs the following steps when called:
- Let S be the
this value. - Return ?
CreateHTML (S,"big" ,"" ,"" ).
B.2.2.4 String.prototype.blink ( )
This method performs the following steps when called:
- Let S be the
this value. - Return ?
CreateHTML (S,"blink" ,"" ,"" ).
B.2.2.5 String.prototype.bold ( )
This method performs the following steps when called:
- Let S be the
this value. - Return ?
CreateHTML (S,"b" ,"" ,"" ).
B.2.2.6 String.prototype.fixed ( )
This method performs the following steps when called:
- Let S be the
this value. - Return ?
CreateHTML (S,"tt" ,"" ,"" ).
B.2.2.7 String.prototype.fontcolor ( color )
This method performs the following steps when called:
- Let S be the
this value. - Return ?
CreateHTML (S,"font" ,"color" , color).
B.2.2.8 String.prototype.fontsize ( size )
This method performs the following steps when called:
- Let S be the
this value. - Return ?
CreateHTML (S,"font" ,"size" , size).
B.2.2.9 String.prototype.italics ( )
This method performs the following steps when called:
- Let S be the
this value. - Return ?
CreateHTML (S,"i" ,"" ,"" ).
B.2.2.10 String.prototype.link ( url )
This method performs the following steps when called:
- Let S be the
this value. - Return ?
CreateHTML (S,"a" ,"href" , url).
B.2.2.11 String.prototype.small ( )
This method performs the following steps when called:
- Let S be the
this value. - Return ?
CreateHTML (S,"small" ,"" ,"" ).
B.2.2.12 String.prototype.strike ( )
This method performs the following steps when called:
- Let S be the
this value. - Return ?
CreateHTML (S,"strike" ,"" ,"" ).
B.2.2.13 String.prototype.sub ( )
This method performs the following steps when called:
- Let S be the
this value. - Return ?
CreateHTML (S,"sub" ,"" ,"" ).
B.2.2.14 String.prototype.sup ( )
This method performs the following steps when called:
- Let S be the
this value. - Return ?
CreateHTML (S,"sup" ,"" ,"" ).
B.2.2.15 String.prototype.trimLeft ( )
The property
The initial value of the
B.2.2.16 String.prototype.trimRight ( )
The property
The initial value of the
B.2.3 Additional Properties of the Date.prototype Object
B.2.3.1 Date.prototype.getYear ( )
The getFullYear
method is preferred for nearly all purposes, because it avoids the “year 2000 problem.”
This method performs the following steps when called:
- Let dateObject be the
this value. - Perform ?
RequireInternalSlot (dateObject, [[DateValue]]). - Let t be dateObject.[[DateValue]].
- If t is
NaN , returnNaN . - Return
YearFromTime (LocalTime (t)) -1900 𝔽.
B.2.3.2 Date.prototype.setYear ( year )
The setFullYear
method is preferred for nearly all purposes, because it avoids the “year 2000 problem.”
This method performs the following steps when called:
- Let dateObject be the
this value. - Perform ?
RequireInternalSlot (dateObject, [[DateValue]]). - Let t be dateObject.[[DateValue]].
- Let y be ?
ToNumber (year). - If t is
NaN , set t to+0 𝔽; otherwise, set t toLocalTime (t). - Let yyyy be
MakeFullYear (y). - Let d be
MakeDay (yyyy,MonthFromTime (t),DateFromTime (t)). - Let date be
MakeDate (d,TimeWithinDay (t)). - Let u be
TimeClip (UTC (date)). - Set dateObject.[[DateValue]] to u.
- Return u.
B.2.3.3 Date.prototype.toGMTString ( )
The toUTCString
method is preferred. This method is provided principally for compatibility with old code.
The initial value of the
B.2.4 Additional Properties of the RegExp.prototype Object
B.2.4.1 RegExp.prototype.compile ( pattern, flags )
This method performs the following steps when called:
- Let O be the
this value. - Perform ?
RequireInternalSlot (O, [[RegExpMatcher]]). - If pattern
is an 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).
This method completely reinitializes the