?
u
m
/
Arrays are
The Array
Array(…)
is equivalent to the object creation expression new Array(…)
with the same arguments.extends
clause of a class definition. Subclass super
call to the Array Array.prototype
methods are generic methods that are not dependent upon their When the Array
function is called, the following steps are taken:
The Array
When the from
method is called, the following steps are taken:
The from
function is an intentionally generic factory method; it does not require that its
When the isArray
method is called, the following steps are taken:
When the of
method is called, the following steps are taken:
The of
function is an intentionally generic factory method; it does not require that its
The value of Array.prototype
is the
This property has the attributes { [[Writable]]:
Array[@@species]
is an
The value of the
Array prototype methods normally use their
The Array prototype object:
The Array prototype object is specified to be an
Returns an array containing the array elements of the object followed by the array elements of each argument.
When the concat
method is called, the following steps are taken:
The concat
method is
The explicit setting of the
The concat
function is intentionally generic; it does not require that its
The abstract operation IsConcatSpreadable takes argument O and returns either a
The initial value of Array.prototype.constructor
is
The end argument is optional. If it is not provided, the length of the
If target is negative, it is treated as
When the copyWithin
method is called, the following steps are taken:
The copyWithin
function is intentionally generic; it does not require that its
When the entries
method is called, the following steps are taken:
callbackfn should be a function that accepts three arguments and returns a value that is coercible to a Boolean value. every
calls callbackfn once for each element present in the array, in ascending order, until it finds one where callbackfn returns every
immediately returns every
will return
If a thisArg parameter is provided, it will be used as the
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
When the every
method is called, the following steps are taken:
The every
function is intentionally generic; it does not require that its
The start argument is optional. If it is not provided,
The end argument is optional. If it is not provided, the length of the
If start is negative, it is treated as
When the fill
method is called, the following steps are taken:
The fill
function is intentionally generic; it does not require that its
callbackfn should be a function that accepts three arguments and returns a value that is coercible to a Boolean value. 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
If a thisArg parameter is provided, it will be used as the
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, the following steps are taken:
The filter
function is intentionally generic; it does not require that its
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 find
immediately returns that element value. Otherwise, find
returns
If a thisArg parameter is provided, it will be used as the
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 predicate. Elements that are appended to the array after the call to find
begins will not be visited by predicate. 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; elements that are deleted after the call to find
begins and before being visited are still visited and are either looked up from the prototype or are
When the find
method is called, the following steps are taken:
The find
function is intentionally generic; it does not require that its
predicate should be a function that accepts three arguments and returns a value that is coercible to a Boolean value. findIndex
calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns 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
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 predicate. Elements that are appended to the array after the call to findIndex
begins will not be visited by predicate. 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; elements that are deleted after the call to findIndex
begins and before being visited are still visited and are either looked up from the prototype or are
When the findIndex
method is called, the following steps are taken:
The findIndex
function is intentionally generic; it does not require that its
When the flat
method is called, the following steps are taken:
The abstract operation FlattenIntoArray takes arguments target (an Object), source (an Object), sourceLen (a non-negative
When the flatMap
method is called, the following steps are taken:
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
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.
The range of elements processed by forEach
is set before the first call to callbackfn. Elements which are appended to the array after the call to forEach
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 forEach
visits them; elements that are deleted after the call to forEach
begins and before being visited are not visited.
When the forEach
method is called, the following steps are taken:
The forEach
function is intentionally generic; it does not require that its
includes
compares searchElement to the elements of the array, in ascending order, using the
The optional second argument fromIndex defaults to
When the includes
method is called, the following steps are taken:
The includes
function is intentionally generic; it does not require that its
The includes
method intentionally differs from the similar indexOf
method in two ways. First, it uses the
indexOf
compares searchElement to the elements of the array, in ascending order, using the
The optional second argument fromIndex defaults to
When the indexOf
method is called, the following steps are taken:
The indexOf
function is intentionally generic; it does not require that its
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.
When the join
method is called, the following steps are taken:
The join
function is intentionally generic; it does not require that its
When the keys
method is called, the following steps are taken:
lastIndexOf
compares searchElement to the elements of the array in descending order using the
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 less than
When the lastIndexOf
method is called, the following steps are taken:
The lastIndexOf
function is intentionally generic; it does not require that its
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
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, the following steps are taken:
The map
function is intentionally generic; it does not require that its
The last element of the array is removed from the array and returned.
When the pop
method is called, the following steps are taken:
The pop
function is intentionally generic; it does not require that its
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, the following steps are taken:
The push
method is
The push
function is intentionally generic; it does not require that its
callbackfn should be a function that takes four arguments. reduce
calls the callback, as a function, once for each element after the first 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 supplied 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 supplied, then previousValue will be equal to the first value in the array and currentValue will be equal to the second. It is a
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, the following steps are taken:
The reduce
function is intentionally generic; it does not require that its
callbackfn should be a function that takes four arguments. reduceRight
calls the callback, as a function, once for each element after the first 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 supplied 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 supplied, 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
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, the following steps are taken:
The reduceRight
function is intentionally generic; it does not require that its
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:
The reverse
function is intentionally generic; it does not require that its
The first element of the array is removed from the array and returned.
When the shift
method is called, the following steps are taken:
The shift
function is intentionally generic; it does not require that its
The slice
method 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
When the slice
method is called, the following steps are taken:
The explicit setting of the
The slice
function is intentionally generic; it does not require that its
callbackfn should be a function that accepts three arguments and returns a value that is coercible to a Boolean value. some
calls callbackfn once for each element present in the array, in ascending order, until it finds one where callbackfn returns some
immediately returns some
returns
If a thisArg parameter is provided, it will be used as the
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
When the some
method is called, the following steps are taken:
The some
function is intentionally generic; it does not require that its
The elements of this array are sorted. The sort must be stable (that is, elements that compare equal must remain in their original order). If comparefn is not
When the sort
method is called, the following steps are taken:
Because non-existent property values always compare greater than
Method calls performed by the
The sort
function is intentionally generic; it does not require that its
The abstract operation SortIndexedProperties takes arguments obj (an Object), len (a non-negative
The sort order is the ordering of items after completion of step
Unless the
Here the notation
An abstract closure or function comparator is a consistent comparator 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
The above conditions are necessary and sufficient to ensure that comparator divides the set S into equivalence classes and that these equivalence classes are totally ordered.
The deleteCount elements of the array starting at
When the splice
method is called, the following steps are taken:
The explicit setting of the
The splice
function is intentionally generic; it does not require that its
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.
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.
When the toLocaleString
method is called, the following steps are taken:
The elements of the array are converted to Strings using their toLocaleString
methods, and these Strings are then concatenated, separated by occurrences of an toString
except that it is intended to yield a locale-sensitive result corresponding with conventions of the
The toLocaleString
function is intentionally generic; it does not require that its
When the toString
method is called, the following steps are taken:
The toString
function is intentionally generic; it does not require that its
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, the following steps are taken:
The unshift
method is
The unshift
function is intentionally generic; it does not require that its
When the values
method is called, the following steps are taken:
The initial value of the
The initial value of the
This property has the attributes { [[Writable]]:
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.
Array instances are
Array instances have a
The
The
Reducing the value of the
An Array Iterator is an object, that represents a specific iteration over some specific Array instance object. There is not a named
The abstract operation CreateArrayIterator takes arguments array (an Object) and kind (
The %ArrayIteratorPrototype% object:
The initial value of the
This property has the attributes { [[Writable]]:
A TypedArray presents an array-like view of an underlying binary data buffer (
|
Element Type | Element Size | Conversion Operation | Description |
---|---|---|---|---|
Int8Array %Int8Array% |
|
1 |
|
8-bit two's complement signed |
Uint8Array %Uint8Array% |
|
1 |
|
8-bit unsigned |
Uint8ClampedArray %Uint8ClampedArray% |
|
1 |
|
8-bit unsigned |
Int16Array %Int16Array% |
|
2 |
|
16-bit two's complement signed |
Uint16Array %Uint16Array% |
|
2 |
|
16-bit unsigned |
Int32Array %Int32Array% |
|
4 |
|
32-bit two's complement signed |
Uint32Array %Uint32Array% |
|
4 |
|
32-bit unsigned |
BigInt64Array %BigInt64Array% |
|
8 |
|
64-bit two's complement signed |
BigUint64Array %BigUint64Array% |
|
8 |
|
64-bit unsigned |
Float32Array %Float32Array% |
|
4 | 32-bit IEEE floating point | |
Float64Array %Float64Array% |
|
8 | 64-bit IEEE floating point |
In the definitions below, references to TypedArray should be replaced with the appropriate
The %TypedArray% intrinsic object:
super
call to it.The
The
The
When the from
method is called, the following steps are taken:
When the of
method is called, the following steps are taken:
The initial value of .prototype
is the
This property has the attributes { [[Writable]]:
[@@species]
is an
The value of the
The %TypedArray% prototype object:
.prototype.buffer
is an
.prototype.byteLength
is an
.prototype.byteOffset
is an
The initial value of .prototype.constructor
is
The interpretation and use of the arguments of .prototype.copyWithin
are the same as for Array.prototype.copyWithin
as defined in
When the copyWithin
method is called, the following steps are taken:
When the entries
method is called, the following steps are taken:
The interpretation and use of the arguments of .prototype.every
are the same as for Array.prototype.every
as defined in
When the every
method is called, the following steps are taken:
This function is not generic. The
The interpretation and use of the arguments of .prototype.fill
are the same as for Array.prototype.fill
as defined in
When the fill
method is called, the following steps are taken:
The interpretation and use of the arguments of .prototype.filter
are the same as for Array.prototype.filter
as defined in
When the filter
method is called, the following steps are taken:
This function is not generic. The
The interpretation and use of the arguments of .prototype.find
are the same as for Array.prototype.find
as defined in
When the find
method is called, the following steps are taken:
This function is not generic. The
The interpretation and use of the arguments of .prototype.findIndex
are the same as for Array.prototype.findIndex
as defined in
When the findIndex
method is called, the following steps are taken:
This function is not generic. The
The interpretation and use of the arguments of .prototype.forEach
are the same as for Array.prototype.forEach
as defined in
When the forEach
method is called, the following steps are taken:
This function is not generic. The
The interpretation and use of the arguments of .prototype.includes
are the same as for Array.prototype.includes
as defined in
When the includes
method is called, the following steps are taken:
This function is not generic. The
The interpretation and use of the arguments of .prototype.indexOf
are the same as for Array.prototype.indexOf
as defined in
When the indexOf
method is called, the following steps are taken:
This function is not generic. The
The interpretation and use of the arguments of .prototype.join
are the same as for Array.prototype.join
as defined in
When the join
method is called, the following steps are taken:
This function is not generic. The
When the keys
method is called, the following steps are taken:
The interpretation and use of the arguments of .prototype.lastIndexOf
are the same as for Array.prototype.lastIndexOf
as defined in
When the lastIndexOf
method is called, the following steps are taken:
This function is not generic. The
.prototype.length
is an
This function is not generic. The
The interpretation and use of the arguments of .prototype.map
are the same as for Array.prototype.map
as defined in
When the map
method is called, the following steps are taken:
This function is not generic. The
The interpretation and use of the arguments of .prototype.reduce
are the same as for Array.prototype.reduce
as defined in
When the reduce
method is called, the following steps are taken:
This function is not generic. The
The interpretation and use of the arguments of .prototype.reduceRight
are the same as for Array.prototype.reduceRight
as defined in
When the reduceRight
method is called, the following steps are taken:
This function is not generic. The
The interpretation and use of the arguments of .prototype.reverse
are the same as for Array.prototype.reverse
as defined in
When the reverse
method is called, the following steps are taken:
This function is not generic. The
.prototype.set
is a function whose behaviour differs based upon the type of its first argument.
This function is not generic. The
Sets multiple values in this TypedArray, reading the values from source. The optional offset value indicates the first element index in this TypedArray where values are written. If omitted, it is assumed to be 0.
When the set
method is called, the following steps are taken:
The abstract operation SetTypedArrayFromTypedArray takes arguments target (a TypedArray), targetOffset (a non-negative
The abstract operation SetTypedArrayFromArrayLike takes arguments target (a TypedArray), targetOffset (a non-negative
The interpretation and use of the arguments of .prototype.slice
are the same as for Array.prototype.slice
as defined in
When the slice
method is called, the following steps are taken:
This function is not generic. The
The interpretation and use of the arguments of .prototype.some
are the same as for Array.prototype.some
as defined in
When the some
method is called, the following steps are taken:
This function is not generic. The
.prototype.sort
is a distinct function that, except as described below, implements the same requirements as those of Array.prototype.sort
as defined in .prototype.sort
specification may be optimized with the knowledge that the
This function is not generic. The
The following steps are performed:
Because
Returns a new TypedArray 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.
When the subarray
method is called, the following steps are taken:
This function is not generic. The
.prototype.toLocaleString
is a distinct function that implements the same algorithm as Array.prototype.toLocaleString
as defined in
This function is not generic.
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
When the values
method is called, the following steps are taken:
The initial value of the
.prototype[@@toStringTag]
is an
This property has the attributes { [[Enumerable]]:
The initial value of the
The abstract operation TypedArraySpeciesCreate takes arguments exemplar (a TypedArray) and argumentList and returns either a
The abstract operation TypedArrayCreate takes arguments constructor and argumentList and returns either a
The abstract operation ValidateTypedArray takes argument O and returns either a
The abstract operation TypedArrayElementSize takes argument O (a TypedArray) and returns a non-negative
The abstract operation TypedArrayElementType takes argument O (a TypedArray) and returns a
Each TypedArray
extends
clause of a class definition. Subclass super
call to the TypedArray .prototype
built-in methods.Each TypedArray
"%TypedArray.prototype%"
.The abstract operation AllocateTypedArray takes arguments constructorName (a String which is the name of a TypedArray
The abstract operation InitializeTypedArrayFromTypedArray takes arguments O (a TypedArray) and srcArray (a TypedArray) and returns either a
The abstract operation InitializeTypedArrayFromArrayBuffer takes arguments O (a TypedArray), buffer (an ArrayBuffer or a SharedArrayBuffer), byteOffset (an
The abstract operation InitializeTypedArrayFromList takes arguments O (a TypedArray) and values (a
The abstract operation InitializeTypedArrayFromArrayLike takes arguments O (a TypedArray) and arrayLike (an Object, but not a TypedArray or an ArrayBuffer) and returns either a
The abstract operation AllocateTypedArrayBuffer takes arguments O (a TypedArray) and length (a non-negative
Each TypedArray
The value of TypedArray.BYTES_PER_ELEMENT
is the Element Size value specified in
This property has the attributes { [[Writable]]:
The initial value of TypedArray.prototype
is the corresponding TypedArray prototype intrinsic object (
This property has the attributes { [[Writable]]:
Each TypedArray prototype object:
The value of TypedArray.prototype.BYTES_PER_ELEMENT
is the Element Size value specified in
This property has the attributes { [[Writable]]:
The initial value of a TypedArray.prototype.constructor
is the corresponding
TypedArray instances are