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:

**Syntax**

*NumericLiteral ***::**

*DecimalLiteralHexIntegerLiteralOctalIntegerLiteral*

*OctalIntegerLiteral ***::**

**0***OctalDigitOctalIntegerLiteral OctalDigit*

*OctalDigit ***::** **one
of**

**0****
****1****
****2****
****3
*** ***4
*** ***5****
****6****
****7**

Semantics

The MV of

*NumericLiteral***::***OctalIntegerLiteral*is the MV of*OctalIntegerLiteral*.The MV of

*OctalDigit***::**

is 0.**0**The MV of

*OctalDigit***::**

is 1.**1**The MV of

*OctalDigit***::**

is 2.**2**The MV of

*OctalDigit***::**

is 3.**3**The MV of

*OctalDigit***::**

is 4.**4**The MV of

*OctalDigit***::**

is 5.**5**The MV of

*OctalDigit***::**

is 6.**6**The MV of

*OctalDigit***::**

is 7.**7**The MV of

*OctalIntegerLiteral***::****0***OctalDigit*is the MV of*OctalDigit*.The MV of

*OctalIntegerLiteral***::***OctalIntegerLiteral**OctalDigit*is (the MV of*OctalIntegerLiteral*times 8) plus 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:

**Syntax**

*EscapeSequence ***::**

*CharacterEscapeSequenceOctalEscapeSequenceHexEscapeSequenceUnicodeEscapeSequence*

*OctalEscapeSequence ***::**

*OctalDigit *[lookahead
∉
*DecimalDigit*]*ZeroToThree
OctalDigit *[lookahead
∉

FourToSeven OctalDigit

ZeroToThree OctalDigit OctalDigit

*ZeroToThree ***::** **one
of**

**0
1 2 3**

*FourToSeven ***::****
****one
of**

**4
5 6 7**

**Semantics**

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, 8^{2}) 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***::**

is 0.**0**The MV of

*ZeroToThree***::**

is 1.**1**The MV of

*ZeroToThree***::**

is 2.**2**The MV of

*ZeroToThree***::**

is 3.**3**The MV of

*FourToSeven***::**

is 4.**4**The MV of

*FourToSeven***::**

is 5.**5**The MV of

*FourToSeven***::**

is 6.**6**The MV of

*FourToSeven***::**

is 7.**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

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.**escape**

For
those characters being replaced whose code unit value is

or less, a two-digit escape sequence of the form **0xFF
****%***xx*
is used. For those characters being replaced whose code unit value
is greater than

,
a four-digit escape sequence of the form **0xFF****%u***xxxx*
is used

When
the

function is called with one argument **escape***string*,
the following steps are taken:

Call ToString(

*string*).Compute the number of characters in Result(1).

Let

*R*be the empty string.Let

*k*be 0.If

*k*equals Result(2), return*R*.Get the character (represented as a 16-bit unsigned integer) at position

*k*within Result(1).If Result(6) is one of the 69 nonblank characters

then go to step 13.**“ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./”**If Result(6), is less than 256, go to step 11.

Let

*S*be a String containing six characters**“%u***wxyz*

where**”***wxyz*are four hexadecimal digits encoding the value of Result(6).Go to step 14.

Let

*S*be a String containing three characters**“%***xy*

where**”***xy*are two hexadecimal digits encoding the value of Result(6).Go to step 14.

Let

*S*be a String containing the single character Result(6).Let

*R*be a new String value computed by concatenating the previous value of*R*and*S*.Increase

*k*by 1.Go to step 5.

**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

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 **unescape**

function is replaced with the character that it represents.**escape**

When
the

function is called with one argument **unescape***string*,
the following steps are taken:

Call ToString(

*string*).Compute the number of characters in Result(1).

Let

*R*be the empty String.Let

*k*be 0.If

*k*equals Result(2), return*R*.Let

*c*be the character at position*k*within Result(1).If

*c*is not

, go to step 18.**%**If

*k*is greater than Result(2)−6, go to step 14.If the character at position

*k*+1 within Result(1) is not

, go to step 14.**u**If the four characters at positions

*k*+2,*k*+3,*k*+4, and*k*+5 within Result(1) are not all hexadecimal digits, go to step 14.Let

*c*be the character whose code unit value is the integer represented by the four hexadecimal digits at positions*k*+2,*k*+3,*k*+4, and*k*+5 within Result(1).Increase k by 5.

Go to step 18.

If

*k*is greater than Result(2)−3, go to step 18.If the two characters at positions

*k*+1 and*k*+2 within Result(1) are not both hexadecimal digits, go to step 18.Let

*c*be the character whose code unit value is the integer represented by two zeroes plus the two hexadecimal digits at positions*k*+1 and*k*+2 within Result(1).Increase

*k*by 2.Let

*R*be a new String value computed by concatenating the previous value of*R*and*c*.Increase

*k*by 1.Go to step 5.

The

method
takes two arguments, **substr***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:

Call ToString, giving it the

**this**value as its argument.Call ToInteger(

*start*).If

*length*is**undefined**, use**+****∞**; otherwise call ToInteger(*length*).Compute the number of characters in Result(1).

If Result(2) is positive or zero, use Result(2); else use max(Result(4)+Result(2),0).

Compute min(max(Result(3),0), Result(4)–Result(5)).

If Result(6) ≤ 0, return the empty String “”.

Return a String containing Result(6) consecutive characters from Result(1) beginning with the character at position Result(5).

The

property of
the **length**

method
is **substr****2**.

**NOTE** The

function is
intentionally generic; it does not require that its **substr****this**
value be a String object. Therefore it can be transferred to other
kinds of objects for use as a method.

**NOTE** The

method
is preferred for nearly all purposes, because it avoids the “year
2000 problem.”**getFullYear**

When
the **getYear** method is called with no arguments, the following
steps are taken:

Let

*t*be this time value.If

*t*is**NaN**, return**NaN**.Return YearFromTime(LocalTime(

*t*)) − 1900.

**NOTE** The

method
is preferred for nearly all purposes, because it avoids the “year
2000 problem.”**setFullYear**

When
the **setYear** method is called with one argument *year*,
the following steps are taken:

Let

*t*be the result of LocalTime(this time value); but if this time value is**NaN**, let*t*be**+0**.Call ToNumber(

*year*).If Result(2) is

**NaN**, set the [[PrimitiveValue]] internal property of the**this**value to**NaN**and return**NaN**.If Result(2) is not

**NaN**and 0 ≤ ToInteger(Result(2)) ≤ 99 then Result(4) is ToInteger(Result(2)) + 1900. Otherwise, Result(4) is Result(2).Compute MakeDay(Result(4), MonthFromTime(

*t*), DateFromTime(*t*)).Compute UTC(MakeDate(Result(5), TimeWithinDay(

*t*))).Set the [[PrimitiveValue]] internal property of the

**this**value to TimeClip(Result(6)).Return the value of the [[PrimitiveValue]] internal property of the

**this**value.

**NOTE** The
property

is preferred. The **toUTCString**

property is provided principally for compatibility with old code. It
is recommended that the **toGMTString**

property be used in new ECMAScript code.**toUTCString**

The
Function object that is the initial value of

is the same Function object that is the initial value of
**Date.prototype.toGMTString**

.**Date.prototype.toUTCString**