?
u
m
/
p
1-9
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 This function performs the following steps when called:
The Array
This method performs the following steps when called:
This method is an intentionally generic factory method; it does not require that its
This function performs the following steps when called:
This method performs the following steps when called:
This method 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[%Symbol.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
This method returns an array containing the array elements of the object followed by the array elements of each argument.
It performs the following steps when called:
The
The explicit setting of the
This method is intentionally generic; it does not require that its
The abstract operation IsConcatSpreadable takes argument O (an
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
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
This method performs the following steps when called:
callback should be a function that accepts three arguments and returns a value that is coercible to a Boolean value. every
calls callback once for each element present in the array, in ascending order, until it finds one where callback returns every
immediately returns every
returns
If a thisArg parameter is provided, it will be used as the
callback 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 callback.
The range of elements processed by every
is set before the first call to callback. Elements which are appended to the array after the call to every
begins will not be visited by callback. If existing elements of the array are changed, their value as passed to callback 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
This method performs the following steps when called:
This method 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
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
callback should be a function that accepts three arguments and returns a value that is coercible to a Boolean value. filter
calls callback once for each element in the array, in ascending order, and constructs a new array of all the values for which callback returns
If a thisArg parameter is provided, it will be used as the
callback 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 callback.
The range of elements processed by filter
is set before the first call to callback. Elements which are appended to the array after the call to filter
begins will not be visited by callback. If existing elements of the array are changed their value as passed to callback 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.
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
This method calls predicate once for each element of the array, in ascending index order, until it finds one where predicate returns a value that coerces to find
immediately returns that element value. Otherwise, find
returns
See
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
This method calls predicate once for each element of the array, in ascending index order, until it finds one where predicate returns a value that coerces to findIndex
immediately returns the index of that element value. Otherwise, findIndex
returns -1.
See
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
This method calls predicate once for each element of the array, in descending index order, until it finds one where predicate returns a value that coerces to findLast
immediately returns that element value. Otherwise, findLast
returns
See
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
This method calls predicate once for each element of the array, in descending index order, until it finds one where predicate returns a value that coerces to findLastIndex
immediately returns the index of that element value. Otherwise, findLastIndex
returns -1.
See
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
The abstract operation FindViaPredicate takes arguments O (an Object), len (a non-negative
O should be an
predicate should be a function. When called for an element of the array, it is passed three arguments: the value of the element, the index of the element, and the object being traversed. Its return value will be coerced to a Boolean value.
thisArg will be used as the
This operation 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 is set before the first call to predicate, just before the traversal begins. Elements that are appended to the array after this 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 this operation visits them. Elements that are deleted after traversal begins and before being visited are still visited and are either looked up from the prototype or are
It performs the following steps when called:
This method performs the following steps when called:
The abstract operation FlattenIntoArray takes arguments target (an Object), source (an Object), sourceLen (a non-negative
This method performs the following steps when called:
callback should be a function that accepts three arguments. forEach
calls callback once for each element present in the array, in ascending order. callback 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
callback 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 callback.
The range of elements processed by forEach
is set before the first call to callback. Elements which are appended to the array after the call to forEach
begins will not be visited by callback. If existing elements of the array are changed, their value as passed to callback 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.
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
This method compares searchElement to the elements of the array, in ascending order, using the
The optional second argument fromIndex defaults to
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
This method intentionally differs from the similar indexOf
method in two ways. First, it uses the
This method compares searchElement to the elements of the array, in ascending order, using the
The optional second argument fromIndex defaults to
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
This method converts the elements of the array to Strings, and then concatenates these Strings, separated by occurrences of the separator. If no separator is provided, a single comma is used as the separator.
It performs the following steps when called:
This method is intentionally generic; it does not require that its
This method performs the following steps when called:
This method 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
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
callback should be a function that accepts three arguments. map
calls callback once for each element in the array, in ascending order, and constructs a new Array from the results. callback 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
callback 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 callback.
The range of elements processed by map
is set before the first call to callback. Elements which are appended to the array after the call to map
begins will not be visited by callback. If existing elements of the array are changed, their value as passed to callback 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.
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
This method removes the last element of the array and returns it.
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
This method appends the arguments to the end of the array, in the order in which they appear. It returns the new length of the array.
This method performs the following steps when called:
The
This method is intentionally generic; it does not require that its
callback 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.
callback is called with four arguments: the previousValue (value from the previous call to callback), 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 initialValue and currentValue will be the first value in the array. If no initialValue was supplied, then previousValue will be the first value in the array and currentValue will be 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 callback.
The range of elements processed by reduce
is set before the first call to callback. Elements that are appended to the array after the call to reduce
begins will not be visited by callback. If existing elements of the array are changed, their value as passed to callback 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.
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
callback 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.
callback is called with four arguments: the previousValue (value from the previous call to callback), 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 initialValue and currentValue will be the last value in the array. If no initialValue was supplied, then previousValue will be the last value in the array and currentValue will be 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 callback.
The range of elements processed by reduceRight
is set before the first call to callback. Elements that are appended to the array after the call to reduceRight
begins will not be visited by callback. If existing elements of the array are changed by callback, their value as passed to callback 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.
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
This method rearranges the elements of the array so as to reverse their order. It returns the reversed array.
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
This method removes the first element of the array and returns it.
It performs the following steps when called:
This method is intentionally generic; it does not require that its
This 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
It performs the following steps when called:
The explicit setting of the
This method is intentionally generic; it does not require that its
callback should be a function that accepts three arguments and returns a value that is coercible to a Boolean value. some
calls callback once for each element present in the array, in ascending order, until it finds one where callback returns some
immediately returns some
returns
If a thisArg parameter is provided, it will be used as the
callback 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 callback.
The range of elements processed by some
is set before the first call to callback. Elements that are appended to the array after the call to some
begins will not be visited by callback. If existing elements of the array are changed, their value as passed to callback 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
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
This method sorts the elements of this array. If comparator is not
It performs the following steps when called:
Because non-existent property values always compare greater than
Method calls performed by the
This method 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 abstract operation CompareArrayElements takes arguments x (an
This method deletes the deleteCount elements of the array starting at
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used.
The first edition of ECMA-402 did not include a replacement specification for this 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.
This method performs the following steps when called:
This method converts the elements of the array to Strings using their toLocaleString
methods, and then concatenates these Strings, separated by occurrences of an toString
except that it is intended to yield a locale-sensitive result corresponding with conventions of the
This method is intentionally generic; it does not require that its
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method is intentionally generic; it does not require that its
This method prepends the arguments 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.
It performs the following steps when called:
The
This method is intentionally generic; it does not require that its
This method performs the following steps when called:
This method performs the following steps when called:
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.
The reason that
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.This function performs the following steps when called:
The
The
This method performs the following steps when called:
This method performs the following steps when called:
The initial value of .prototype
is the
This property has the attributes { [[Writable]]:
[%Symbol.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 this method are the same as for Array.prototype.copyWithin
as defined in
This method performs the following steps when called:
This method performs the following steps when called:
The interpretation and use of the arguments of this method are the same as for Array.prototype.every
as defined in
This method performs the following steps when called:
This method is not generic. The
The interpretation and use of the arguments of this method are the same as for Array.prototype.fill
as defined in
This method performs the following steps when called:
The interpretation and use of the arguments of this method are the same as for Array.prototype.filter
as defined in
This method performs the following steps when called:
This method is not generic. The
The interpretation and use of the arguments of this method are the same as for Array.prototype.find
as defined in
This method performs the following steps when called:
This method is not generic. The
The interpretation and use of the arguments of this method are the same as for Array.prototype.findIndex
as defined in
This method performs the following steps when called:
This method is not generic. The
The interpretation and use of the arguments of this method are the same as for Array.prototype.findLast
as defined in
This method performs the following steps when called:
This method is not generic. The
The interpretation and use of the arguments of this method are the same as for Array.prototype.findLastIndex
as defined in
This method performs the following steps when called:
This method is not generic. The
The interpretation and use of the arguments of this method are the same as for Array.prototype.forEach
as defined in
This method performs the following steps when called:
This method is not generic. The
The interpretation and use of the arguments of this method are the same as for Array.prototype.includes
as defined in
This method performs the following steps when called:
This method is not generic. The
The interpretation and use of the arguments of this method are the same as for Array.prototype.indexOf
as defined in
This method performs the following steps when called:
This method is not generic. The
The interpretation and use of the arguments of this method are the same as for Array.prototype.join
as defined in
This method performs the following steps when called:
This method is not generic. The
This method performs the following steps when called:
The interpretation and use of the arguments of this method are the same as for Array.prototype.lastIndexOf
as defined in
This method performs the following steps when called:
This method is not generic. The
.prototype.length
is an
This function is not generic. The
The interpretation and use of the arguments of this method are the same as for Array.prototype.map
as defined in
This method performs the following steps when called:
This method is not generic. The
The interpretation and use of the arguments of this method are the same as for Array.prototype.reduce
as defined in
This method performs the following steps when called:
This method is not generic. The
The interpretation and use of the arguments of this method are the same as for Array.prototype.reduceRight
as defined in
This method performs the following steps when called:
This method is not generic. The
The interpretation and use of the arguments of this method are the same as for Array.prototype.reverse
as defined in
This method performs the following steps when called:
This method is not generic. The
This method sets multiple values in this TypedArray, reading the values from source. The details differ based upon the type of 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.
It performs the following steps when called:
This method is not generic. The
The abstract operation SetTypedArrayFromTypedArray takes arguments target (a
The abstract operation SetTypedArrayFromArrayLike takes arguments target (a
The interpretation and use of the arguments of this method are the same as for Array.prototype.slice
as defined in
This method performs the following steps when called:
This method is not generic. The
The interpretation and use of the arguments of this method are the same as for Array.prototype.some
as defined in
This method performs the following steps when called:
This method is not generic. The
This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort
as defined in
This method is not generic. The
It performs the following steps when called:
Because
This method returns a new TypedArray whose element type is the element type of this TypedArray and whose ArrayBuffer is the ArrayBuffer of this TypedArray, referencing the elements in the
It performs the following steps when called:
This method is not generic. The
This is a distinct method that implements the same algorithm as Array.prototype.toLocaleString
as defined in
This method is not generic.
If the ECMAScript implementation includes the ECMA-402 Internationalization API this method is based upon the algorithm for Array.prototype.toLocaleString
that is in the ECMA-402 specification.
This method performs the following steps when called:
This method performs the following steps when called:
The initial value of the
This method performs the following steps when called:
This method performs the following steps when called:
The initial value of the
.prototype[%Symbol.toStringTag%]
is an
This property has the attributes { [[Enumerable]]:
The initial value of the
The abstract operation TypedArraySpeciesCreate takes arguments exemplar (a
The abstract operation TypedArrayCreateFromConstructor takes arguments constructor (a
The abstract operation TypedArrayCreateSameType takes arguments exemplar (a
The abstract operation ValidateTypedArray takes arguments O (an
The abstract operation TypedArrayElementSize takes argument O (a
The abstract operation TypedArrayElementType takes argument O (a
The abstract operation CompareTypedArrayElements takes arguments x (a Number or a BigInt), y (a Number or a BigInt), and comparator (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
The abstract operation InitializeTypedArrayFromTypedArray takes arguments O (a
The abstract operation InitializeTypedArrayFromArrayBuffer takes arguments O (a
The abstract operation InitializeTypedArrayFromList takes arguments O (a
The abstract operation InitializeTypedArrayFromArrayLike takes arguments O (a
The abstract operation AllocateTypedArrayBuffer takes arguments O (a
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 the
TypedArray instances are