Past editions of ECMAScript have included additional syntax and semantics for specifying octal literals and octal escape sequences. These have been removed from this edition of ECMAScript. This non-normative annex presents uniform syntax and semantics for octal literals and octal escape sequences for compatibility with some older ECMAScript programs.
The syntax and semantics of 7.8.3 can be extended as follows except that this extension is not allowed for strict mode code:
0
OctalDigit0
1
2
3
4
5
6
7
Semantics
0
is 0.1
is 1.2
is 2.3
is 3.4
is 4.5
is 5.6
is 6.7
is 7.0
OctalDigit is the MV of OctalDigit.The syntax and semantics of 7.8.4 can be extended as follows except that this extension is not allowed for strict mode code:
0
1
2
3
4
5
6
7
The CV of EscapeSequence :: OctalEscapeSequence is the CV of the OctalEscapeSequence.
The CV of OctalEscapeSequence :: OctalDigit [lookahead ∉ DecimalDigit] is the character whose code unit value is the MV of the OctalDigit.
The CV of OctalEscapeSequence :: ZeroToThree OctalDigit [lookahead ∉ DecimalDigit] is the character whose code unit value is (8 times the MV of the ZeroToThree) plus the MV of the OctalDigit.
The CV of OctalEscapeSequence :: FourToSeven OctalDigit is the character whose code unit value is (8 times the MV of the FourToSeven) plus the MV of the OctalDigit.
The CV of OctalEscapeSequence :: ZeroToThree OctalDigit OctalDigit is the character whose code unit value is (64 (that is, 82) times the MV of the ZeroToThree) plus (8 times the MV of the first OctalDigit) plus the MV of the second OctalDigit.
The MV of ZeroToThree :: 0
is 0.
The MV of ZeroToThree :: 1
is 1.
The MV of ZeroToThree :: 2
is 2.
The MV of ZeroToThree :: 3
is 3.
The MV of FourToSeven :: 4
is 4.
The MV of FourToSeven :: 5
is 5.
The MV of FourToSeven :: 6
is 6.
The MV of FourToSeven :: 7
is 7.
Some implementations of ECMAScript have included additional properties for some of the standard native objects. This non-normative annex suggests uniform semantics for such properties without making the properties or their semantics part of this standard.
The escape
function is a property of the global object. It computes a new version of a String value in which
certain characters have been replaced by a hexadecimal escape sequence.
For those characters being replaced whose code unit value is 0xFF
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
0xFF
, a four-digit escape sequence of the form %u
xxxx is used.
When the escape
function is called with one argument string, the following steps are taken:
“ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./”
then
go to step 13.“%u
wxyz”
where
wxyz are four hexadecimal digits encoding the value of Result(6).“%
xy”
where
xy are two hexadecimal digits encoding the value of Result(6).NOTE 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.
The unescape
function is a property of the global object. It computes a new version of a String value in
which each escape sequence of the sort that might be introduced by the escape
function is replaced with the
character that it represents.
When the unescape
function is called with one argument string, the following steps are taken:
%
, go to step 18.u
, go to step 14.The substr
method takes two arguments, start and length, and returns a substring of the result of converting the this object to a String, starting from character position start and running for length characters (or through the end of the String if length is undefined). If start is negative, it is treated as (sourceLength+start) where sourceLength is the length of the String. The result is a String value, not a String object. The following steps are taken:
The length
property of the substr
method is 2.
NOTE The substr
function is intentionally generic; it does not require that its
this value be a String object. Therefore it can be transferred to other kinds of objects for use as a method.
NOTE 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:
NOTE 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:
NOTE 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 Function object that is the initial value of Date.prototype.toGMTString
is the same Function object that
is the initial value of Date.prototype.toUTCString
.