Array objects are exotic objects that give special treatment to a certain class of property names. See 9.4.2 for a definition of this special treatment.
The Array constructor is the %Array% intrinsic object and the initial value of the Array
property of the
global object. When called as a constructor it creates and initializes a new exotic Array object. When Array
is called as a function rather than as a constructor, it also creates and initializes a new Array object. Thus the
function call Array(…)
is equivalent to the object creation expression
new Array(…)
with the same arguments.
The Array
constructor is a single function whose behaviour is overloaded based upon the number and types
of its arguments.
The Array
constructor is designed to be subclassable. It may be used as the value of an
extends
clause of a class definition. Subclass constructors that intend to inherit the exotic
Array
behaviour must include a super
call to the Array
constructor to initialize
subclass instances that are exotic Array objects. However, most of the Array.prototype
methods are generic
methods that are not dependent upon their this
value being an exotic Array object.
The length
property of the Array
constructor function is 1.
This description applies if and only if the Array constructor is called with no arguments.
"%ArrayPrototype%"
).This description applies if and only if the Array constructor is called with exactly one argument.
"%ArrayPrototype%"
)."0"
, len)."length"
, intLen,
true).This description applies if and only if the Array constructor is called with at least two arguments.
When the Array
function is called the following steps are taken:
"%ArrayPrototype%"
).length
property is
numberOfArgs.The value of the [[Prototype]] internal slot of the Array constructor is the intrinsic object %FunctionPrototype% (19.2.3).
Besides the length
property (whose value is 1), the Array constructor has the following
properties:
When the from
method is called with argument items and optional arguments
mapfn and thisArg the following steps are taken:
"length"
,
k, true)."length"
))."length"
, len,
true).The length
property of the from
method is 1.
NOTE The from
function is an intentionally generic factory method; it does not
require that its this value be the Array constructor. Therefore it can be transferred to or inherited by any
other constructors that may be called with a single numeric argument.
The isArray
function takes one argument arg, and performs the following
steps:
When the of
method is called with any number of arguments, the following steps are
taken:
"length"
, len,
true).The length
property of the of
method is 0.
NOTE 1 The items argument is assumed to be a well-formed rest argument value.
NOTE 2 The of
function is an intentionally generic factory method; it does not
require that its this value be the Array constructor. Therefore it can be transferred to or inherited by other
constructors that may be called with a single numeric argument.
The value of Array.prototype
is %ArrayPrototype%, the intrinsic Array prototype object (22.1.3).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
Array[@@species]
is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:
The value of the name
property of this function is "get [Symbol.species]"
.
NOTE Array prototype methods normally use their this
object’s constructor
to create a derived object. However, a subclass constructor may over-ride that default behaviour by redefining its
@@species property.
The Array prototype object is the intrinsic object %ArrayPrototype%. The Array prototype object is an Array exotic
objects and has the internal methods specified for such objects. It has a length
property whose initial value
is 0 and whose attributes are { [[Writable]]: true, [[Enumerable]]:
false, [[Configurable]]: false }.
The value of the [[Prototype]] internal slot of the Array prototype object is the intrinsic object %ObjectPrototype%.
NOTE The Array prototype object is specified to be an Array exotic object to ensure compatibility with ECMAScript code that was created prior to the ECMAScript 2015 specification.
When the concat
method is called with zero or more arguments, it returns an array containing the array
elements of the object followed by the array elements of each argument in order.
The following steps are taken:
"length"
))."length"
, n,
true).The length
property of the concat
method is 1.
NOTE 1 The explicit setting of the length
property in step 8 is necessary to
ensure that its value is correct in situations where the trailing elements of the result Array are not present.
NOTE 2 The concat
function 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.
The abstract operation IsConcatSpreadable with argument O performs the following steps:
The initial value of Array.prototype.constructor
is the intrinsic object %Array%.
The copyWithin
method takes up to three arguments target, start
and end.
NOTE 1 The end argument is optional with the length of the this object as its default value. If target is negative, it is treated as length+target where length is the length of the array. If start is negative, it is treated as length+start. If end is negative, it is treated as length+end.
The following steps are taken:
"length"
)).The length
property of the copyWithin
method is 2.
NOTE 2 The copyWithin
function 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.
The following steps are taken:
"key+value"
).NOTE 1 callbackfn should be a function that accepts three arguments and returns a
value that is coercible to the Boolean value true or false. every
calls callbackfn
once for each element present in the array, in ascending order, until it finds one where callbackfn returns
false. If such an element is found, every
immediately returns false. Otherwise, if
callbackfn returned true for all elements, every
will return true.
callbackfn is called only for elements of the array which actually exist; it is not called for missing
elements of the array.
If a thisArg parameter is provided, it will be used as the this value for each invocation of callbackfn. If it is not provided, undefined is used instead.
callbackfn is called with three arguments: the value of the element, the index of the element, and the object being traversed.
every
does not directly mutate the object on which it is called but the object may be
mutated by the calls to callbackfn.
The range of elements processed by every
is set before the first call to
callbackfn. Elements which are appended to the array after the call to every
begins will not be
visited by callbackfn. If existing elements of the array are changed, their value as passed to
callbackfn will be the value at the time every
visits them; elements that are deleted after the
call to every
begins and before being visited are not visited. every
acts like the "for all"
quantifier in mathematics. In particular, for an empty array, it returns true.
When the every
method is called with one or two arguments, the following steps are
taken:
"length"
)).The length
property of the every
method is 1.
NOTE 2 The every
function 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.
The fill
method takes up to three arguments value, start and
end.
NOTE 1 The start and end arguments are optional with default values of 0 and the length of the this object. If start is negative, it is treated as length+start where length is the length of the array. If end is negative, it is treated as length+end.
The following steps are taken:
"length"
)).The length
property of the fill
method is 1.
NOTE 2 The fill
function 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.
NOTE 1 callbackfn should be a function that accepts three arguments and returns a
value that is coercible to the Boolean value true or false. filter
calls
callbackfn once for each element in the array, in ascending order, and constructs a new array of all the
values for which callbackfn returns true. callbackfn is called only for elements of the
array which actually exist; it is not called for missing elements of the array.
If a thisArg parameter is provided, it will be used as the this value for each invocation of callbackfn. If it is not provided, undefined is used instead.
callbackfn is called with three arguments: the value of the element, the index of the element, and the object being traversed.
filter
does not directly mutate the object on which it is called but the object may be
mutated by the calls to callbackfn.
The range of elements processed by filter
is set before the first call to
callbackfn. Elements which are appended to the array after the call to filter
begins will not be
visited by callbackfn. If existing elements of the array are changed their value as passed to
callbackfn will be the value at the time filter
visits them; elements that are deleted after the
call to filter
begins and before being visited are not visited.
When the filter
method is called with one or two arguments, the following steps are
taken:
"length"
)).The length
property of the filter
method is 1.
NOTE 2 The filter
function 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.
The find
method is called with one or two arguments, predicate and
thisArg.
NOTE 1 predicate should be a function that accepts three arguments and returns a
value that is coercible to a Boolean value. find
calls predicate once for each element of the
array, in ascending order, until it finds one where predicate returns true. If
such an element is found, find
immediately returns that element value. Otherwise, find
returns
undefined.
If a thisArg parameter is provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.
predicate is called with three arguments: the value of the element, the index of the element, and the object being traversed.
find
does not directly mutate the object on which it is called but the object may be
mutated by the calls to predicate.
The range of elements processed by find
is set before the first call to
callbackfn. Elements that are appended to the array after the call to find
begins will not be
visited by callbackfn. If existing elements of the array are changed, their value as passed to
predicate will be the value at the time that find
visits them.
When the find
method is called, the following steps are taken:
"length"
)).The length
property of the find
method is 1.
NOTE 2 The find
function 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.
NOTE 1 predicate should be a function that accepts three arguments and returns a
value that is coercible to the Boolean value true or false. findIndex
calls
predicate once for each element of the array, in ascending order, until it finds one where
predicate returns true. If such an element is found, findIndex
immediately returns the
index of that element value. Otherwise, findIndex
returns -1.
If a thisArg parameter is provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.
predicate is called with three arguments: the value of the element, the index of the element, and the object being traversed.
findIndex
does not directly mutate the object on which it is called but the object may be
mutated by the calls to predicate.
The range of elements processed by findIndex
is set before the first call to
callbackfn. Elements that are appended to the array after the call to findIndex
begins will not be
visited by callbackfn. If existing elements of the array are changed, their value as passed to
predicate will be the value at the time that findIndex
visits them.
When the findIndex
method is called with one or two arguments, the following steps
are taken:
"length"
)).The length
property of the findIndex
method is 1.
NOTE 2 The findIndex
function 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.
NOTE 1 callbackfn should be a function that accepts three arguments.
forEach
calls callbackfn once for each element present in the array, in ascending order.
callbackfn is called only for elements of the array which actually exist; it is not called for missing
elements of the array.
If a thisArg parameter is provided, it will be used as the this value for each invocation of callbackfn. If it is not provided, undefined is used instead.
callbackfn is called with three arguments: the value of the element, the index of the element, and the object being traversed.
forEach
does not directly mutate the object on which it is called but the object may be mutated by the
calls to callbackfn.
When the forEach
method is called with one or two arguments, the following steps are
taken:
"length"
)).The length
property of the forEach
method is 1.
NOTE 2 The forEach
function 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.
NOTE 1 indexOf
compares searchElement to the elements of the array,
in ascending order, using the Strict Equality Comparison algorithm (7.2.13), and if found at one or more indices, returns the smallest such
index; otherwise, −1 is returned.
The optional second argument fromIndex defaults to 0 (i.e. the whole array is searched). If it is greater than or equal to the length of the array, −1 is returned, i.e. the array will not be searched. If it is negative, it is used as the offset from the end of the array to compute fromIndex. If the computed index is less than 0, the whole array will be searched.
When the indexOf
method is called with one or two arguments, the following steps are
taken:
"length"
)).The length
property of the indexOf
method is 1.
NOTE 2 The indexOf
function 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.
NOTE 1 The elements of the array are converted to Strings, and these Strings are then concatenated, separated by occurrences of the separator. If no separator is provided, a single comma is used as the separator.
The join
method takes one argument, separator, and performs the following
steps:
"length"
)).","
."0"
).1
.The length
property of the join
method is 1.
NOTE 2 The join
function 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.
The following steps are taken:
"key"
).NOTE 1 lastIndexOf
compares searchElement to the elements of the
array in descending order using the Strict Equality Comparison algorithm (7.2.13), and if found at one or more indices, returns the largest such index;
otherwise, −1 is returned.
The optional second argument fromIndex defaults to the array's length minus one (i.e. the whole array is searched). If it is greater than or equal to the length of the array, the whole array will be searched. If it is negative, it is used as the offset from the end of the array to compute fromIndex. If the computed index is less than 0, −1 is returned.
When the lastIndexOf
method is called with one or two arguments, the following steps
are taken:
"length"
)).The length
property of the lastIndexOf
method is 1.
NOTE 2 The lastIndexOf
function 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.
NOTE 1 callbackfn should be a function that accepts three arguments.
map
calls callbackfn once for each element in the array, in ascending order, and constructs a
new Array from the results. callbackfn is called only for elements of the array which actually exist; it is
not called for missing elements of the array.
If a thisArg parameter is provided, it will be used as the this value for each invocation of callbackfn. If it is not provided, undefined is used instead.
callbackfn is called with three arguments: the value of the element, the index of the element, and the object being traversed.
map
does not directly mutate the object on which it is called but the object may be mutated by the calls
to callbackfn.
The range of elements processed by map
is set before the first call to callbackfn. Elements
which are appended to the array after the call to map
begins will not be visited by callbackfn.
If existing elements of the array are changed, their value as passed to callbackfn will be the value at the
time map
visits them; elements that are deleted after the call to map
begins and before being
visited are not visited.
When the map
method is called with one or two arguments, the following steps are
taken:
"length"
)).The length
property of the map
method is 1.
NOTE 2 The map
function 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.
NOTE 1 The last element of the array is removed from the array and returned.
When the pop
method is called the following steps are taken:
"length"
))."length"
, 0,
true)."length"
, newLen,
true).NOTE 2 The pop
function 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.
NOTE 1 The arguments are appended to the end of the array, in the order in which they appear. The new length of the array is returned as the result of the call.
When the push
method is called with zero or more arguments the following steps are
taken:
"length"
))."length"
, len,
true).The length
property of the push
method is 1.
NOTE 2 The push
function 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.
NOTE 1 callbackfn should be a function that takes four arguments.
reduce
calls the callback, as a function, once for each element present in the array, in ascending
order.
callbackfn is called with four arguments: the previousValue (value from the previous call to
callbackfn), the currentValue (value of the current element), the currentIndex, and the object
being traversed. The first time that callback is called, the previousValue and currentValue can be one of
two values. If an initialValue was provided in the call to reduce
, then previousValue
will be equal to initialValue and currentValue will be equal to the first value in the array. If no
initialValue was provided, then previousValue will be equal to the first value in the array and
currentValue will be equal to the second. It is a TypeError if the array contains no elements and
initialValue is not provided.
reduce
does not directly mutate the object on which it is called but the object may be mutated by the
calls to callbackfn.
The range of elements processed by reduce
is set before the first call to callbackfn.
Elements that are appended to the array after the call to reduce
begins will not be visited by
callbackfn. If existing elements of the array are changed, their value as passed to callbackfn
will be the value at the time reduce
visits them; elements that are deleted after the call to
reduce
begins and before being visited are not visited.
When the reduce
method is called with one or two arguments, the following steps are
taken:
"length"
)).The length
property of the reduce
method is 1.
NOTE 2 The reduce
function 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.
NOTE 1 callbackfn should be a function that takes four arguments.
reduceRight
calls the callback, as a function, once for each element present in the array, in descending
order.
callbackfn is called with four arguments: the previousValue (value from the previous call to
callbackfn), the currentValue (value of the current element), the currentIndex, and the
object being traversed. The first time the function is called, the previousValue and currentValue
can be one of two values. If an initialValue was provided in the call to reduceRight
, then
previousValue will be equal to initialValue and currentValue will be equal to the last
value in the array. If no initialValue was provided, then previousValue will be equal to the last
value in the array and currentValue will be equal to the second-to-last value. It is a TypeError if
the array contains no elements and initialValue is not provided.
reduceRight
does not directly mutate the object on which it is called but the object may be mutated by
the calls to callbackfn.
The range of elements processed by reduceRight
is set before the first call to callbackfn.
Elements that are appended to the array after the call to reduceRight
begins will not be visited by
callbackfn. If existing elements of the array are changed by callbackfn, their value as passed to
callbackfn will be the value at the time reduceRight
visits them; elements that are deleted
after the call to reduceRight
begins and before being visited are not visited.
When the reduceRight
method is called with one or two arguments, the following steps
are taken:
"length"
)).The length
property of the reduceRight
method is 1.
NOTE 2 The reduceRight
function 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.
NOTE 1 The elements of the array are rearranged so as to reverse their order. The object is returned as the result of the call.
When the reverse
method is called the following steps are taken:
"length"
)).NOTE 2 The reverse
function 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.
NOTE 1 The first element of the array is removed from the array and returned.
When the shift
method is called the following steps are taken:
"length"
))."length"
, 0,
true)."0"
)."length"
, len–1,
true).NOTE 2 The shift
function 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.
NOTE 1 The slice
method takes two arguments, start and
end, and returns an array containing the elements of the array from element start up to, but not
including, element end (or through the end of the array if end is undefined). If
start is negative, it is treated as length+start where length is the length of the array. If end is
negative, it is treated as length+end where
length is the length of the array.
The following steps are taken:
"length"
))."length"
, n,
true).The length
property of the slice
method is 2.
NOTE 2 The explicit setting of the length
property of the result Array in step
16 is necessary to ensure that its value is correct in situations where the trailing elements of the result Array are
not present.
NOTE 3 The slice
function 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.
NOTE 1 callbackfn should be a function that accepts three arguments and returns a
value that is coercible to the Boolean value true or false. some
calls callbackfn
once for each element present in the array, in ascending order, until it finds one where callbackfn returns
true. If such an element is found, some
immediately returns true. Otherwise,
some
returns false. callbackfn is called only for elements of the array which actually
exist; it is not called for missing elements of the array.
If a thisArg parameter is provided, it will be used as the this value for each invocation of callbackfn. If it is not provided, undefined is used instead.
callbackfn is called with three arguments: the value of the element, the index of the element, and the object being traversed.
some
does not directly mutate the object on which it is called but the object may be mutated by the
calls to callbackfn.
The range of elements processed by some
is set before the first call to callbackfn. Elements
that are appended to the array after the call to some
begins will not be visited by callbackfn.
If existing elements of the array are changed, their value as passed to callbackfn will be the value at the
time that some
visits them; elements that are deleted after the call to some
begins and before
being visited are not visited. some
acts like the "exists" quantifier in mathematics. In particular, for an
empty array, it returns false.
When the some
method is called with one or two arguments, the following steps are
taken:
"length"
)).The length
property of the some
method is 1.
NOTE 2 The some
function 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.
The elements of this array are sorted. The sort is not necessarily stable (that is, elements that compare equal do not necessarily remain in their original order). If comparefn is not undefined, it should be a function that accepts two arguments x and y and returns a negative value if x < y, zero if x = y, or a positive value if x > y.
Upon entry, the following steps are performed to initialize evaluation of the sort
function:
"length"
)).Within this specification of the sort
method, an object, obj, is said
to be sparse if the following algorithm returns true:
The sort order is the ordering, after completion of this function, of the integer indexed property values of
obj whose integer indexes are less than len. The result of the sort
function is then
determined as follows:
If comparefn is not undefined and is not a consistent comparison function for the elements of this array (see below), the sort order is implementation-defined. The sort order is also implementation-defined if comparefn is undefined and SortCompare ({ REF _Ref393437395 \n \h }22.1.3.24.1) does not act as a consistent comparison function.
Let proto be obj.[[GetPrototypeOf]](). If proto is not null and there exists an integer j such that all of the conditions below are satisfied then the sort order is implementation-defined:
The sort order is also implementation defined if obj is sparse and any of the following conditions are true:
IsExtensible(obj) is false.
Any integer index property of obj whose name is a nonnegative integer less than len is a data property whose [[Configurable]] attribute is false.
The sort order is also implementation defined if any of the following conditions are true:
If obj is an exotic object (including Proxy exotic objects) whose behaviour for [[Get]], [[Set]], [[Delete]], and [[GetOwnProperty]] is not the ordinary object implementation of these internal methods.
If any index index property of obj whose name is a nonnegative integer less than len is an accessor property or is a data property whose [[Writable]] attribute is false.
If comparefn is undefined and the application of ToString to any value passed as an argument to SortCompare modifies obj or any object on obj’s prototype chain.
If comparefn is undefined and all applications of ToString, to any specific value passed as an argument to SortCompare, do not produce the same result.
The following steps are taken:
The property key argument for each call to [[Get]], [[Set]], HasOwnProperty, or DeletePropertyOrThrow is the string representation of a nonnegative integer less than len.
The arguments for calls to SortCompare are values returned by a previous call to the [[Get]] internal method, unless the properties accessed by those previous calls did not exist according to HasOwnProperty. If both perspective arguments to SortCompare correspond to non-existent properties, use +0 instead of calling SortCompare. If only the first perspective argument is non-existent use +1. If only the second perspective argument is non-existent use −1.
If obj is not sparse then DeletePropertyOrThrow must not be called.
If any [[Set]] call returns false a TypeError exception is thrown.
If an abrupt completion is returned from any of these operations, it is immediately returned as the value of this function.
Unless the sort order is specified above to be implementation-defined, the returned object must have the following two characteristics:
There must be some mathematical permutation π of the nonnegative integers less than len, such that for every nonnegative integer j less than len, if property old[j] existed, then new[π(j)] is exactly the same value as old[j]. But if property old[j] did not exist, then new[π(j)] does not exist.
Then for all nonnegative integers j and k, each less than len, if SortCompare(old[j], old[k]) < 0 (see SortCompare below), then new[π(j)] < new[π(k)].
Here the notation old[j] is used to refer to the hypothetical result of calling the [[Get]] internal method of obj with argument j before this function is executed, and the notation new[j] to refer to the hypothetical result of calling the [[Get]] internal method of obj with argument j after this function has been executed.
A function comparefn is a consistent comparison function for a set of values S if all of the requirements below are met for all values a, b, and c (possibly the same value) in the set S: The notation a <CF b means comparefn(a,b) < 0; a =CF b means comparefn(a,b) = 0 (of either sign); and a >CF b means comparefn(a,b) > 0.
Calling comparefn(a,b) always returns the same value v when given a specific pair of values a and b as its two arguments. Furthermore, Type(v) is Number, and v is not NaN. Note that this implies that exactly one of a <CF b, a =CF b, and a >CF b will be true for a given pair of a and b.
Calling comparefn(a,b) does not modify obj or any object on obj’s prototype chain.
a =CF a (reflexivity)
If a =CF b, then b =CF a (symmetry)
If a =CF b and b =CF c, then a =CF c (transitivity of =CF)
If a <CF b and b <CF c, then a <CF c (transitivity of <CF)
If a >CF b and b >CF c, then a >CF c (transitivity of >CF)
NOTE 1 The above conditions are necessary and sufficient to ensure that comparefn divides the set S into equivalence classes and that these equivalence classes are totally ordered.
NOTE 2 The sort
function 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.
The SortCompare abstract operation is called with two arguments x and y.
It also has access to the comparefn argument passed to the current invocation of the sort
method. The following steps are taken:
NOTE 1 Because non-existent property values always compare greater than undefined property values, and undefined always compares greater than any other value, undefined property values always sort to the end of the result, followed by non-existent property values.
NOTE 2 Method calls performed by the ToString abstract operations in steps 5 and 7 have the potential to cause SortCompare to not behave as a consistent comparison function.
NOTE 1 When the splice
method is called with two or more arguments
start, deleteCount and zero or more items, the deleteCount elements of the
array starting at integer index start are replaced by the arguments items. An Array object
containing the deleted elements (if any) is returned.
The following steps are taken:
"length"
))."length"
,
actualDeleteCount, true)."length"
, len –
actualDeleteCount + itemCount, true).The length
property of the splice
method is 2.
NOTE 2 The explicit setting of the length
property of the result Array in step
24 is necessary to ensure that its value is correct in situations where its trailing elements are not present.
NOTE 3 The splice
function 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.
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the
Array.prototype.toLocaleString
method as specified in the ECMA-402 specification. If an ECMAScript
implementation does not include the ECMA-402 API the following specification of the toLocaleString
method is
used.
NOTE 1 The first edition of ECMA-402 did not include a replacement specification for the
Array.prototype.toLocaleString
method.
The meanings of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
The following steps are taken:
"length"
))."0"
)."toLocaleString"
)).1
."toLocaleString"
)).NOTE 2 The elements of the array are converted to Strings using their
toLocaleString
methods, and these Strings are then concatenated, separated by occurrences of a separator
String that has been derived in an implementation-defined locale-specific way. The result of calling this function is
intended to be analogous to the result of toString
, except that the result of this function is intended to
be locale-specific.
NOTE 3 The toLocaleString
function 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.
When the toString
method is called, the following steps are taken:
"join"
).NOTE The toString
function 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.
NOTE 1 The arguments are prepended to the start of the array, such that their order within the array is the same as the order in which they appear in the argument list.
When the unshift
method is called with zero or more arguments item1,
item2, etc., the following steps are taken:
"length"
))."length"
,
len+argCount, true).The length
property of the unshift
method is 1.
NOTE 2 The unshift
function 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.
The following steps are taken:
"value"
).This function is the %ArrayProto_values% intrinsic object.
The initial value of the @@iterator property is the same function object as the initial value of the Array.prototype.values property.
The initial value of the @@unscopables data property is an object created by the following steps:
"copyWithin"
,
true)."entries"
,
true)."fill"
,
true)."find"
,
true)."findIndex"
,
true)."keys"
,
true)."values"
,
true).This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
NOTE The own property names of this object are property names that were not included as
standard properties of Array.prototype
prior to the ECMAScript 2015 specification. These names are ignored
for with
statement binding purposes in order to preserve the behaviour of existing code that might use one
of these names as a binding in an outer scope that is shadowed by a with
statement whose binding object is
an Array object.
Array instances are Array exotic objects and have the internal methods specified for such objects. Array instances inherit properties from the Array prototype object.
Array instances have a length
property, and a set of enumerable properties with array index names.
The length
property of an Array instance is a data property whose value is always numerically greater than
the name of every configurable own property whose name is an array index.
The length
property initially has the attributes {
[[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }.
NOTE Reducing the value of the length
property has the side-effect of deleting
own array elements whose array index is between the old and new length values. However, non-configurable properties can
not be deleted. Attempting to set the length property of an Array object to a value that is numerically less than or
equal to the largest numeric own property name of an existing non-configurable array indexed property of the array will
result in the length being set to a numeric value that is one greater than that non-configurable numeric own property
name. See 9.4.2.1.
An Array Iterator is an object, that represents a specific iteration over some specific Array instance object. There is not a named constructor for Array Iterator objects. Instead, Array iterator objects are created by calling certain methods of Array instance objects.
Several methods of Array objects return Iterator objects. The abstract operation CreateArrayIterator with arguments array and kind is used to create such iterator objects. It performs the following steps:
All Array Iterator Objects inherit properties from the %ArrayIteratorPrototype% intrinsic object. The %ArrayIteratorPrototype% object is an ordinary object and its [[Prototype]] internal slot is the %IteratorPrototype% intrinsic object (25.1.2). In addition, %ArrayIteratorPrototype% has the following properties:
"length"
)).key
", return CreateIterResultObject(index, false).value
", let result be elementValue.key+value
".The initial value of the @@toStringTag property is the String value "Array Iterator"
.
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
Array Iterator instances are ordinary objects that inherit properties from the %ArrayIteratorPrototype% intrinsic object. Array Iterator instances are initially created with the internal slots listed in Table 48.
Internal Slot | Description |
---|---|
[[IteratedObject]] | The object whose array elements are being iterated. |
[[ArrayIteratorNextIndex]] | The integer index of the next integer index to be examined by this iteration. |
[[ArrayIterationKind]] | A String value that identifies what is returned for each element of the iteration. The possible values are: "key" , "value" , "key+value" . |
TypedArray objects present an array-like view of an underlying binary data buffer (24.1). Each element of a TypedArray instance has the same underlying binary scalar data type. There is a distinct TypedArray constructor, listed in Table 49, for each of the nine supported element types. Each constructor in Table 49 has a corresponding distinct prototype object.
Constructor Name and Intrinsic | Element Type | Element Size | Conversion Operation | Description | Equivalent C Type |
---|---|---|---|---|---|
Int8Array %Int8Array% |
Int8 | 1 | ToInt8 | 8-bit 2’s complement signed integer | signed char |
Uint8Array %Uint8Array% |
Uint8 | 1 | ToUint8 | 8-bit unsigned integer | unsigned char |
Uint8ClampedArray %Uint8ClampedArray% |
Uint8C | 1 | ToUint8Clamp | 8-bit unsigned integer (clamped conversion) | unsigned char |
Int16Array %Int16Array% |
Int16 | 2 | ToInt16 | 16-bit 2’s complement signed integer | short |
Uint16Array %Uint16Array% |
Uint16 | 2 | ToUint16 | 16-bit unsigned integer | unsigned short |
Int32Array %Int32Array% |
Int32 | 4 | ToInt32 | 32-bit 2’s complement signed integer | int |
Uint32Array %Uint32Array% |
Uint32 | 4 | ToUint32 | 32-bit unsigned integer | unsigned int |
Float32Array %Float32Array% |
Float32 | 4 | 32-bit IEEE floating point | float | |
Float64Array %Float64Array% |
Float64 | 8 | 64-bit IEEE floating point | double |
In the definitions below, references to TypedArray should be replaced with the appropriate constructor name from the above table. The phrase “the element size in bytes” refers to the value in the Element Size column of the table in the row corresponding to the constructor. The phrase “element Type” refers to the value in the Element Type column for that row.
The %TypedArray% intrinsic object is a constructor function object that all of the TypedArray constructor object inherit from. %TypedArray% and its corresponding prototype object provide common properties that are inherited by all TypedArray constructors and their instances. The %TypedArray% intrinsic does not have a global name or appear as a property of the global object.
The %TypedArray% intrinsic function object is designed to act as the superclass of the various TypedArray
constructors. Those constructors use %TypedArray% to initialize their instances by invoking %TypedArray% as if by making a
super
call. The %TypedArray% intrinsic function is not designed to be directly called in any other way. If
%TypedArray% is directly called or called as part of a new
expression an exception is thrown.
The %TypedArray% intrinsic constructor function is a single function whose behaviour is overloaded based upon the
number and types of its arguments. The actual behaviour of a super
call of %TypedArray% depends upon the
number and kind of arguments that are passed to it.
This description applies only if the %TypedArray% function is called with no arguments.
This description applies only if the %TypedArray% function is called with at least one argument and the Type of the first argument is not Object.
%TypedArray% called with argument length performs the following steps:
The abstract operation AllocateTypedArray with argument newTarget and optional argument length is used to validate and create an instance of a TypedArray constructor. If the length argument is passed an ArrayBuffer of that length is also allocated and associated with the new TypedArray instance. AllocateTypedArray provides common semantics that is used by all of the %TypeArray% overloads and other methods. AllocateTypedArray performs the following steps:
new
operator. It can only be successfully invoked by a SuperCall."%TypedArrayPrototype%"
).This description applies only if the %TypedArray% function is called with at least one argument and the Type of the first argument is Object and that object has a [[TypedArrayName]] internal slot.
%TypedArray% called with argument typedArray performs the following steps:
This description applies only if the %TypedArray% function is called with at least one argument and the Type of the first argument is Object and that object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] internal slot.
%TypedArray% called with argument object performs the following steps:
This description applies only if the %TypedArray% function is called with at least one argument and the Type of the first argument is Object and that object has an [[ArrayBufferData]] internal slot.
%TypedArray% called with arguments buffer, byteOffset, and length performs the following steps:
The value of the [[Prototype]] internal slot of %TypedArray% is the intrinsic object %FunctionPrototype% (19.2.3).
Besides a length
property whose value is 3 and a name
property whose value is
"TypedArray"
, %TypedArray% has the following properties:
When the from
method is called with argument source, and optional
arguments mapfn and thisArg, the following steps are taken:
The length
property of the from
method is 1.
When the TypedArrayFrom abstract operation is called with arguments constructor, items, mapfn, and thisArg, the following steps are taken:
"length"
)).When the of
method is called with any number of arguments, the following steps are
taken:
The length
property of the of
method is 0.
NOTE The items argument is assumed to be a well-formed rest argument value.
The initial value of %TypedArray%.prototype is the %TypedArrayPrototype% intrinsic object (22.2.3).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
%TypedArray%[@@species] is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:
The value of the name
property of this function is "get [Symbol.species]"
.
NOTE %TypedArrayPrototype% methods normally use their this
object’s
constructor to create a derived object. However, a subclass constructor may over-ride that default behaviour by
redefining its @@species property.
The value of the [[Prototype]] internal slot of the %TypedArrayPrototype% object is the intrinsic object %ObjectPrototype% (19.1.3). The %TypedArrayPrototype% object is an ordinary object. It does not have a [[ViewedArrayBuffer]] or any other of the internal slots that are specific to TypedArray instance objects.
%TypedArray%.prototype.buffer
is an accessor property whose set accessor function is
undefined. Its get accessor function performs the following steps:
%TypedArray%.prototype.byteLength
is an accessor property whose set accessor function
is undefined. Its get accessor function performs the following steps:
%TypedArray%.prototype.byteOffset
is an accessor property whose set accessor function
is undefined. Its get accessor function performs the following steps:
The initial value of %TypedArray%.prototype.constructor is the %TypedArray% intrinsic object.
%TypedArray%.prototype.copyWithin
is a distinct function that implements the same algorithm as Array.prototype.copyWithin
as defined in 22.1.3.3 except that the this object’s [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of
"length"
and the actual copying of values in step 17 must be performed in a manner that preserves the
bit-level encoding of the source data
The implementation of the algorithm may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer indexed properties are not sparse. However, such optimization must not introduce any observable changes in the specified behaviour of the algorithm.
This function is not generic. ValidateTypedArray is applied to the this value prior to evaluating the algorithm. If its result is an abrupt completion that exception is thrown instead of evaluating the algorithm.
The length
property of the copyWithin
method is 2.
When called with argument O the following steps are taken:
The following steps are taken:
"key+value"
).%TypedArray%.prototype.every
is a distinct function that implements the same algorithm as Array.prototype.every
as defined in 22.1.3.5 except that the this object’s [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of
"length"
. The implementation of the algorithm may be optimized with the knowledge that the this value
is an object that has a fixed length and whose integer indexed properties are not sparse. However, such optimization must
not introduce any observable changes in the specified behaviour of the algorithm and must take into account the
possibility that calls to callbackfn may cause the this value to become detached.
This function is not generic. ValidateTypedArray is applied to the this value prior to evaluating the algorithm. If its result is an abrupt completion that exception is thrown instead of evaluating the algorithm.
The length
property of the every
method is 1.
%TypedArray%.prototype.fill
is a distinct function that implements the same algorithm as Array.prototype.fill
as defined in 22.1.3.6 except that the this object’s [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of
"length"
. The implementation of the algorithm may be optimized with the knowledge that the this value
is an object that has a fixed length and whose integer indexed properties are not sparse. However, such optimization must
not introduce any observable changes in the specified behaviour of the algorithm.
This function is not generic. ValidateTypedArray is applied to the this value prior to evaluating the algorithm. If its result is an abrupt completion that exception is thrown instead of evaluating the algorithm.
The length
property of the fill
method is 1.
The interpretation and use of the arguments of %TypedArray%.prototype.filter
are the same as for Array.prototype.filter
as defined in 22.1.3.7.
When the filter
method is called with one or two arguments, the following steps are
taken:
This function is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.
The length
property of the filter
method is 1.
%TypedArray%.prototype.find
is a distinct function that implements the same algorithm as Array.prototype.find
as defined in 22.1.3.8 except that the this object’s [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of
"length"
. The implementation of the algorithm may be optimized with the knowledge that the this value
is an object that has a fixed length and whose integer indexed properties are not sparse. However, such optimization must
not introduce any observable changes in the specified behaviour of the algorithm and must take into account the
possibility that calls to predicate may cause the this value to become detached.
This function is not generic. ValidateTypedArray is applied to the this value prior to evaluating the algorithm. If its result is an abrupt completion that exception is thrown instead of evaluating the algorithm.
The length
property of the find
method is 1.
%TypedArray%.prototype.findIndex
is a distinct function that implements the same algorithm as Array.prototype.findIndex
as defined in 22.1.3.9 except that the this object’s [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of
"length"
. The implementation of the algorithm may be optimized with the knowledge that the this value
is an object that has a fixed length and whose integer indexed properties are not sparse. However, such optimization must
not introduce any observable changes in the specified behaviour of the algorithm and must take into account the
possibility that calls to predicate may cause the this value to become detached.
This function is not generic. ValidateTypedArray is applied to the this value prior to evaluating the algorithm. If its result is an abrupt completion that exception is thrown instead of evaluating the algorithm.
The length
property of the findIndex
method is 1.
%TypedArray%.prototype.forEach
is a distinct function that implements the same algorithm as Array.prototype.forEach
as defined in 22.1.3.10 except that the this object’s [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of
"length"
. The implementation of the algorithm may be optimized with the knowledge that the this value
is an object that has a fixed length and whose integer indexed properties are not sparse. However, such optimization must
not introduce any observable changes in the specified behaviour of the algorithm and must take into account the
possibility that calls to callbackfn may cause the this value to become detached.
This function is not generic. ValidateTypedArray is applied to the this value prior to evaluating the algorithm. If its result is an abrupt completion that exception is thrown instead of evaluating the algorithm.
The length
property of the forEach
method is 1.
%TypedArray%.prototype.indexOf
is a distinct function that implements the same algorithm as Array.prototype.indexOf
as defined in 22.1.3.11 except that the this object’s [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of
"length"
. The implementation of the algorithm may be optimized with the knowledge that the this value
is an object that has a fixed length and whose integer indexed properties are not sparse. However, such optimization must
not introduce any observable changes in the specified behaviour of the algorithm.
This function is not generic. ValidateTypedArray is applied to the this value prior to evaluating the algorithm. If its result is an abrupt completion that exception is thrown instead of evaluating the algorithm.
The length
property of the indexOf
method is 1.
%TypedArray%.prototype.join
is a distinct function that implements the same algorithm as Array.prototype.join
as defined in 22.1.3.12 except that the this object’s [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of
"length"
. The implementation of the algorithm may be optimized with the knowledge that the this value
is an object that has a fixed length and whose integer indexed properties are not sparse. However, such optimization must
not introduce any observable changes in the specified behaviour of the algorithm.
This function is not generic. ValidateTypedArray is applied to the this value prior to evaluating the algorithm. If its result is an abrupt completion that exception is thrown instead of evaluating the algorithm.
The following steps are taken:
"key"
).%TypedArray%.prototype.lastIndexOf
is a distinct function that implements the same algorithm as Array.prototype.lastIndexOf
as defined in 22.1.3.14 except that the this object’s [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of
"length"
. The implementation of the algorithm may be optimized with the knowledge that the this value
is an object that has a fixed length and whose integer indexed properties are not sparse. However, such optimization must
not introduce any observable changes in the specified behaviour of the algorithm.
This function is not generic. ValidateTypedArray is applied to the this value prior to evaluating the algorithm. If its result is an abrupt completion that exception is thrown instead of evaluating the algorithm.
The length
property of the lastIndexOf
method is 1.
%TypedArray%.prototype.length
is an accessor property whose set accessor function is
undefined. Its get accessor function performs the following steps:
This function is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.
The interpretation and use of the arguments of %TypedArray%.prototype.map
are the same as for Array.prototype.map
as defined in 22.1.3.15.
When the map
method is called with one or two arguments, the following steps are
taken:
This function is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.
The length
property of the map
method is 1.
%TypedArray%.prototype.reduce
is a distinct function that implements the same algorithm as Array.prototype.reduce
as defined in 22.1.3.18 except that the this object’s [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of
"length"
. The implementation of the algorithm may be optimized with the knowledge that the this value
is an object that has a fixed length and whose integer indexed properties are not sparse. However, such optimization must
not introduce any observable changes in the specified behaviour of the algorithm and must take into account the
possibility that calls to callbackfn may cause the this value to become detached.
This function is not generic. ValidateTypedArray is applied to the this value prior to evaluating the algorithm. If its result is an abrupt completion that exception is thrown instead of evaluating the algorithm.
The length
property of the reduce
method is 1.
%TypedArray%.prototype.reduceRight
is a distinct function that implements the same algorithm as Array.prototype.reduceRight
as defined in 22.1.3.19 except that the this object’s [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of
"length"
. The implementation of the algorithm may be optimized with the knowledge that the this value
is an object that has a fixed length and whose integer indexed properties are not sparse. However, such optimization must
not introduce any observable changes in the specified behaviour of the algorithm and must take into account the
possibility that calls to callbackfn may cause the this value to become detached.
This function is not generic. ValidateTypedArray is applied to the this value prior to evaluating the algorithm. If its result is an abrupt completion that exception is thrown instead of evaluating the algorithm.
The length
property of the reduceRight
method is 1.
%TypedArray%.prototype.reverse
is a distinct function that implements the same algorithm as Array.prototype.reverse
as defined in 22.1.3.20 except that the this object’s [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of
"length"
. The implementation of the algorithm may be optimized with the knowledge that the this value
is an object that has a fixed length and whose integer indexed properties are not sparse. However, such optimization must
not introduce any observable changes in the specified behaviour of the algorithm.
This function is not generic. ValidateTypedArray is applied to the this value prior to evaluating the algorithm. If its result is an abrupt completion that exception is thrown instead of evaluating the algorithm.
%TypedArray%.prototype.set
is a single function whose behaviour is overloaded based upon the type of its
first argument.
This function is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.
The length
property of the set
method is 1.
Sets multiple values in this TypedArray, reading the values from the object array. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.
"length"
)).Sets multiple values in this TypedArray, reading the values from the typedArray argument object. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.
"Uint8"
)."Uint8"
, value).The interpretation and use of the arguments of %TypedArray%.prototype.slice
are the
same as for Array.prototype.slice
as defined in 22.1.3.22. The following steps are taken:
"Uint8"
)."Uint8"
, value).This function is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.
The length
property of the slice
method is 2.
%TypedArray%.prototype.some
is a distinct function that implements the same algorithm as Array.prototype.some
as defined in 22.1.3.23 except that the this object’s [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of
"length"
. The implementation of the algorithm may be optimized with the knowledge that the this value
is an object that has a fixed length and whose integer indexed properties are not sparse. However, such optimization must
not introduce any observable changes in the specified behaviour of the algorithm and must take into account the
possibility that calls to callbackfn may cause the this value to become detached.
This function is not generic. ValidateTypedArray is applied to the this value prior to evaluating the algorithm. If its result is an abrupt completion that exception is thrown instead of evaluating the algorithm.
The length
property of the some
method is 1.
%TypedArray%.prototype.sort
is a distinct function that, except as described below, implements the same
requirements as those of Array.prototype.sort
as defined in 22.1.3.24. The implementation of the %TypedArray%.prototype.sort
specification may be optimized with the knowledge that the this value is an object that has a fixed length and
whose integer indexed properties are not sparse. The only internal methods of the this object that the algorithm
may call are [[Get]] and [[Set]].
This function is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.
Upon entry, the following steps are performed to initialize evaluation of the sort
function. These steps are used instead of the entry steps in 22.1.3.24:
The implementation defined sort order condition for exotic objects is not applied by
%TypedArray%.prototype.sort
.
The following version of SortCompare is used by
%TypedArray%.prototype.sort
. It performs a numeric comparison rather than the string comparison used in 22.1.3.24. SortCompare has access to the
comparefn and buffer values of the current invocation of the sort
method.
When the TypedArray SortCompare abstract operation is called with two arguments x and y, the following steps are taken:
NOTE Because NaN always compares greater than any other value, NaN property values always sort to the end of the result when comparefn is not provided.
Returns a new TypedArray object whose element type is the same as this TypedArray and whose ArrayBuffer is the same as the ArrayBuffer of this TypedArray, referencing the elements at begin, inclusive, up to end, exclusive. If either begin or end is negative, it refers to an index from the end of the array, as opposed to from the beginning.
This function is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.
The length
property of the subarray
method is 2.
%TypedArray%.prototype.toLocaleString
is a distinct function that implements the same algorithm as
Array.prototype.
toLocaleString
as defined in 22.1.3.26 except that the this object’s [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of
"length"
. The implementation of the algorithm may be optimized with the knowledge that the this value
is an object that has a fixed length and whose integer indexed properties are not sparse. However, such optimization must
not introduce any observable changes in the specified behaviour of the algorithm.
This function is not generic. ValidateTypedArray is applied to the this value prior to evaluating the algorithm. If its result is an abrupt completion that exception is thrown instead of evaluating the algorithm.
NOTE If the ECMAScript implementation includes the ECMA-402 Internationalization API this
function is based upon the algorithm for Array.prototype.toLocaleString
that is in the ECMA-402
specification.
The initial value of the %TypedArray%.prototype.toString
data property is the same built-in function
object as the Array.prototype.toString
method defined in 22.1.3.27.
The following steps are taken:
"value"
).The initial value of the @@iterator property is the same function object as the initial value of the
%TypedArray%.prototype.values
property.
%TypedArray%.prototype[@@toStringTag]
is an accessor property whose set accessor
function is undefined. Its get accessor function performs the following steps:
This property has the attributes { [[Enumerable]]: false, [[Configurable]]: true }.
The initial value of the name
property of this function is "get [Symbol.toStringTag]"
.
Each of the TypedArray constructor objects is an intrinsic object that has the structure described below, differing only in the name used as the constructor name instead of TypedArray, in Table 49.
The TypedArray constructors are not intended to be called as a function and will throw an exception when called in that manner.
The TypedArray constructors are designed to be subclassable. They may be used as the value of an
extends
clause of a class definition. Subclass constructors that intend to inherit the specified
TypedArray behaviour must include a super
call to the TypedArray constructor to create and
initialize the subclass instance with the internal state necessary to support the %TypedArray%.prototype
built-in methods.
A TypedArray constructor with a list of arguments argumentsList performs the following steps:
The value of the [[Prototype]] internal slot of each TypedArray constructor is the %TypedArray% intrinsic object (22.2.1).
Each TypedArray constructor has a [[TypedArrayConstructorName]] internal slot property whose value is the String value of the constructor name specified for it in Table 49.
Each TypedArray constructor has a name
property whose value is the String value of the constructor
name specified for it in Table 49.
Besides a length
property (whose value is 3), each TypedArray constructor has the following
properties:
The value of TypedArray.BYTES_PER_ELEMENT is the Number value of the Element Size value specified in Table 49 for TypedArray.
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The initial value of TypedArray.prototype is the corresponding TypedArray prototype intrinsic object (22.2.6).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The value of the [[Prototype]] internal slot of a TypedArray prototype object is the intrinsic object %TypedArrayPrototype% (22.2.3). A TypedArray prototype object is an ordinary object. It does not have a [[ViewedArrayBuffer]] or any other of the internal slots that are specific to TypedArray instance objects.
The value of TypedArray.prototype.BYTES_PER_ELEMENT
is the Number value of the Element Size value
specified in Table 49 for TypedArray.
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The initial value of a TypedArray.prototype.constructor
is the corresponding %TypedArray%
intrinsic object.
TypedArray instances are Integer Indexed exotic objects. Each TypedArray instance inherits properties from the corresponding TypedArray prototype object. Each TypedArray instance has the following internal slots: [[TypedArrayName]], [[ViewedArrayBuffer]], [[ByteLength]], [[ByteOffset]], and [[ArrayLength]].