Methods
(static) from(_arrayLike, _mapFnopt, _thisArgopt) → {Array}
The Array.from() method creates a new Array instance from an array-like or iterable object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
_arrayLike |
object | An array-like or iterable object to convert to an array. |
|
_mapFn |
function |
<optional> |
Optional. Map function to call on every element of the array. |
_thisArg |
object |
<optional> |
Optional. Value to use as this when executing mapFn. |
- Source:
Returns:
The created Array.
- Type
- Array
(static) isArray(_arg) → {boolean}
Check if an object is an array.
Parameters:
Name | Type | Description |
---|---|---|
_arg |
The object to check. |
- Source:
Returns:
true if an object is an array, false if it is not.
- Type
- boolean
(static) of(…_value) → {Array}
The Array.of() method creates a new Array instance with a variable number of arguments, regardless of number or type of the arguments.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
_value |
any |
<repeatable> |
Any number of values that will be the content of the array. |
- Source:
Returns:
The created Array.
- Type
- Array
every(_callback, _thisArgopt) → {boolean}
Check if callback returns true for every element
This:
- {Array}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
_callback |
function | The callback to test each value |
|
_thisArg |
object |
<optional> |
Optional: the context in which the callback should be invoked |
- Source:
Returns:
True if the callback returns true for each element, false otherwise.
- Type
- boolean
fill(_value, _startopt, _endopt)
The fill() method fills all the elements of an array from a start index to an end index with a static value.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
_value |
The value to set to each index |
|||
_start |
number |
<optional> |
0 | Optional: the index to start filling (inclusive) If _start is negative, it is treated as length + _start. |
_end |
number |
<optional> |
Optional: the index at which to stop filling (exclusive) If _end is negative, it is treated as length + _end. |
- Source:
filter(_callback, _thisArgopt) → {Array}
Creates a new array with only the elements matching the provided function.
This:
- {Array}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
_callback |
function | The callback to test each value. |
|
_thisArg |
object |
<optional> |
Optional: the context in which the callback should be invoked |
- Source:
Returns:
A new array containing the result of callback per element.
- Type
- Array
find(_callback, _thisArgopt)
Find a value in the array
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
_callback |
function | The callback to test each value in the array. If the value matches, it should return true. |
|
_thisArg |
object |
<optional> |
Optional: the context in which the callback should be invoked |
- Source:
Returns:
the found value or undefined if not found.
findIndex(_callback, _thisArgopt) → {number}
Find a value in the array
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
_callback |
function | The callback to test each value in the array. If the value matches, it should return true. |
|
_thisArg |
object |
<optional> |
Optional: the context in which the callback should be invoked |
- Source:
Returns:
the found index or -1 if not found.
- Type
- number
forEach(_callback, _thisArgopt)
Enumerate all values in the array
This:
- {Array}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
_callback |
function | The callback to call for each value |
|
_thisArg |
object |
<optional> |
Optional: the context in which the callback should be invoked |
- Source:
includes(_searchElement, _fromIndexopt) → {boolean}
The includes() method determines whether an array includes a certain element, returning true or false as appropriate. The array is searched forwards, starting at fromIndex (defaults to 0).
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
_searchElement |
object | Element to locate in the array. |
||
_fromIndex |
object |
<optional> |
0 | Optional: The index to start the search at. Default: 0 If the index is greater than or equal to the array's length, -1 is returned, which means the array will not be searched. If the provided index value is a negative number, it is taken as the offset from the end of the array. Note: if the provided index is negative, the array is still searched from front to back. If the calculated index is less than 0, then the whole array will be searched. |
- Source:
Returns:
True if the element was found, false otherwise.
- Type
- boolean
indexOf(_searchElement, _fromIndexopt) → {number}
Returns the first index at which a given element can be found in the array, or -1 if it is not present.
This:
- {Array}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
_searchElement |
object | Element to locate in the array. |
||
_fromIndex |
number |
<optional> |
0 | Optional: The index to start the search at. Default: 0 If the index is greater than or equal to the array's length, -1 is returned, which means the array will not be searched. If the provided index value is a negative number, it is taken as the offset from the end of the array. Note: if the provided index is negative, the array is still searched from front to back. If the calculated index is less than 0, then the whole array will be searched. |
- Source:
Returns:
The first index at which a given element can be found in the array, or -1 if it is not present.
- Type
- number
lastIndexOf(_searchElement, _fromIndexopt) → {number}
Returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at fromIndex.
This:
- {Array}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
_searchElement |
object | Element to locate in the array. |
||
_fromIndex |
number |
<optional> |
-1 | Optional: The index at which to start searching backwards. Defaults to the array's length - 1, i.e. the whole array will be searched. If the index is greater than or equal to the length of the array, the whole array will be searched. If negative, it is taken as the offset from the end of the array. Note that even when the index is negative, the array is still searched from back to front. If the calculated index is less than 0, -1 is returned, i.e. the array will not be searched. |
- Source:
Returns:
The last index at which a given element can be found in the array, or -1 if it is not present.
- Type
- number
map(_callback, _thisArgopt) → {Array}
Creates a new array with the results of calling a provided function on every element in this array.
This:
- {Array}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
_callback |
function | The callback to test each value |
|
_thisArg |
object |
<optional> |
Optional: the context in which the callback should be invoked |
- Source:
Returns:
A new array containing the result of callback per element.
- Type
- Array
reduce(_callback, _initialValueopt)
The reduce() method applies a function against an accumulator and each value of the array (from left-to-right) has to reduce it to a single value.
This:
- {Array}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
_callback |
function | The callback to call for each value, taking 4 arguments: previousValue The value previously returned in the last invocation of the callback, or initialValue, if supplied. (See below.) currentValue The current element being processed in the array. index The index of the current element being processed in the array. array The array reduce was called upon. |
|
_initialValue |
object |
<optional> |
Optional: a value to pass to the first callback. |
- Source:
reduceRight(_callback, _initialValueopt)
The reduceRight() method applies a function against an accumulator and each value of the array (from right-to-left) has to reduce it to a single value.
This:
- {Array}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
_callback |
function | The callback to call for each value, taking 4 arguments: previousValue The value previously returned in the last invocation of the callback, or initialValue, if supplied. (See below.) currentValue The current element being processed in the array. index The index of the current element being processed in the array. array The array reduce was called upon. |
|
_initialValue |
object |
<optional> |
Optional: a value to pass to the first callback. |
- Source:
some(_callback, _thisArgopt) → {boolean}
Check if callback returns true for any element
This:
- {Array}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
_callback |
function | The callback to test each value |
|
_thisArg |
object |
<optional> |
Optional: the context in which the callback should be invoked |
- Source:
Returns:
True if the callback returns true for at least one element, false otherwise.
- Type
- boolean