[ Pobierz całość w formacie PDF ]
11. Go to step 13.
12. Call the [[Delete]] method of this object with argument Result(7).
13. Decrease k by 1.
14. Go to step 5.
15. Let k be 0.
16. Get the next argument in the part of the argument list that starts with item1; if there are no more
arguments, go to step 21.
17. Call ToString(k).
18. Call the [[Put]] method of this object with arguments Result(17) and Result(16).
19. Increase k by 1.
20. Go to step 16.
21. Call the [[Put]] method of this object with arguments"length"and (Result(2)+Result(3)).
22. Return (Result(2)+Result(3)).
Thelengthproperty of theunshiftmethod is 1.
NOTE
Theunshiftfunction is intentionally generic; it does not require that its this value be an Array
object. Therefore it can be transferred to other kinds of objects for use as a method. Whether the
unshiftfunction can be applied successfully to a host object is implementation-dependent.
15.4.5 Properties of Array Instances
Array instances inherit properties from the Array prototype object and also have the following
properties.
15.4.5.1 [[Put]] (P, V)
Array objects use a variation of the [[Put]] method used for other native ECMAScript objects
(8.6.2.2).
Assume A is an Array object and P is a string.
When the [[Put]] method of A is called with property P and value V, the following steps are taken:
1. Call the [[CanPut]] method of A with name P.
2. If Result(1) is false, return.
3. If A doesn t have a property with name P, go to step 7.
4. If P is"length", go to step 12.
5. Set the value of property P of A to V.
6. Go to step 8.
7. Create a property with name P, set its value to V and give it empty attributes.
8. If P is not an array index, return.
9. If ToUint32(P) is less than the value of thelengthproperty of A, then return.
10. Change (or set) the value of thelengthproperty of A to ToUint32(P)+1.
11. Return.
12. Compute ToUint32(V).
13. If Result(12) is not equal to ToNumber(V), throw a RangeError exception.
14. For every integer k that is less than the value of thelengthproperty of A but not less than
Result(12), if A itself has a property (not an inherited property) named ToString(k), then delete
that property.
- 98 -
15. Set the value of property P of A to Result(12).
16. Return.
15.4.5.2 length
The length property of this Array object is always numerically greater than the name of every
property whose name is an array index.
Thelengthproperty has the attributes { DontEnum, DontDelete }.
15.5 String Objects
15.5.1 The String Constructor Called as a Function
WhenStringis called as a function rather than as a constructor, it performs a type conversion.
15.5.1.1 String ( [ value ] )
Returns a string value (not a String object) computed by ToString(value). If value is not supplied, the
empty string""is returned.
15.5.2 The String Constructor
WhenStringis called as part of anewexpression, it is a constructor: it initialises the newly created
object.
15.5.2.1 new String ( [ value ] )
The [[Prototype]] property of the newly constructed object is set to the original String prototype
object, the one that is the initial value ofString.prototype(15.5.3.1).
The [[Class]] property of the newly constructed object is set to"String".
The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty
string if value is not supplied.
15.5.3 Properties of the String Constructor
The value of the internal [[Prototype]] property of the String constructor is the Function prototype object
(15.3.4).
Besides the internal properties and thelengthproperty (whose value is 1), the String constructor has
the following properties:
15.5.3.1 String.prototype
The initial value ofString.prototypeis the String prototype object (15.5.4).
This property has the attributes { DontEnum, DontDelete, ReadOnly }.
15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , & ] ] ] )
Returns a string value containing as many characters as the number of arguments. Each argument
specifies one character of the resulting string, with the first argument specifying the first character,
and so on, from left to right. An argument is converted to a character by applying the operation
ToUint16 (9.7) and regarding the resulting 16-bit integer as the code point value of a character. If no
arguments are supplied, the result is the empty string.
Thelengthproperty of thefromCharCodefunction is 1.
15.5.4 Properties of the String Prototype Object
The String prototype object is itself a String object (its [[Class]] is"String") whose value is an empty
string.
The value of the internal [[Prototype]] property of the String prototype object is the Object prototype
object (15.2.3.1).
15.5.4.1 String.prototype.constructor
The initial value ofString.prototype.constructoris the built-inStringconstructor.
- 99 -
15.5.4.2 String.prototype.toString ( )
Returns this string value. (Note that, for a String object, thetoStringmethod happens to return the
same thing as thevalueOfmethod.)
ThetoStringfunction is not generic; it throws a TypeError exception if its this value is not a
String object. Therefore, it cannot be transferred to other kinds of objects for use as a method.
15.5.4.3 String.prototype.valueOf ( )
Returns this string value.
ThevalueOffunction is not generic; it throws a TypeError exception if its this value is not a
String object. Therefore, it cannot be transferred to other kinds of objects for use as a method.
15.5.4.4 String.prototype.charAt (pos)
Returns a string containing the character at position pos in the string resulting from converting this
object to a string. If there is no character at that position, the result is the empty string. The result is a
string value, not a String object.
If pos is a value of Number type that is an integer, then the result ofx.charAt(pos)is equal to the
result ofx.substring(pos,pos+1).
When thecharAtmethod is called with one argument pos, the following steps are taken:
1. Call ToString, giving it the this value as its argument.
2. Call ToInteger(pos).
3. Compute the number of characters in Result(1).
4. If Result(2) is less than 0 or is not less than Result(3), return the empty string.
5. Return a string of length 1, containing one character from Result(1), namely the character at
position Result(2), where the first (leftmost) character in Result(1) is considered to be at position
0, the next one at position 1, and so on.
NOTE
The charAt 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.
15.5.4.5 String.prototype.charCodeAt (pos)
Returns a number (a nonnegative integer less than 216) representing the code point value of the
character at position pos in the string resulting from converting this object to a string. If there is no
character at that position, the result is NaN.
When thecharCodeAtmethod is called with one argument pos, the following steps are taken:
1. Call ToString, giving it the this value as its argument.
2. Call ToInteger(pos).
3. Compute the number of characters in Result(1).
4. If Result(2) is less than 0 or is not less than Result(3), return NaN.
5. Return a value of Number type, whose value is the code point value of the character at position
Result(2) in the string Result(1), where the first (leftmost) character in Result(1) is considered to
be at position 0, the next one at position 1, and so on.
NOTE
ThecharCodeAtfunction is intentionally generic; it does not require that its this value be a String
[ Pobierz całość w formacie PDF ]