README
utiljs-arrays
JavaScript utility methods for arrays
utiljs-arrays is part of Util.js.
This class contains all the non-instance methods of Array in addition to:
Arrays API
Kind: global class
Access: public
- Arrays
- .from(arrayLike, [mapFn], [thisArg]) ⇒
Array
- .isArray(obj) ⇒
boolean
- .of(...elementN) ⇒
Array
- .shuffle(array) ⇒
Array
- .from(arrayLike, [mapFn], [thisArg]) ⇒
Array
arrays.from(arrayLike, [mapFn], [thisArg]) ⇒ Creates a new, shallow-copied Array instance from an array-like or iterable object.
See MDN's documentation about from.
Kind: instance method of Arrays
Returns: Array
- A new Array instance
Access: public
Param | Type | Description |
---|---|---|
arrayLike | An array-like or iterable object to convert to an array | |
[mapFn] | function |
Map function to call on every element of the array |
[thisArg] | Object |
Value to use as this when executing mapFn |
boolean
arrays.isArray(obj) ⇒ Determines whether the passed value is an Array.
See MDN's documentation about isArray.
Kind: instance method of Arrays
Returns: boolean
- true if the object is an Array or false otherwise
Access: public
Param | Type | Description |
---|---|---|
obj | * |
The object to be checked |
Array
arrays.of(...elementN) ⇒ Creates a new Array instance with a variable number of arguments, regardless of number or type of the arguments
See MDN's documentation about of.
Kind: instance method of Arrays
Returns: Array
- A new Array instance
Access: public
Param | Type | Description |
---|---|---|
...elementN | * |
Elements of which to create the array |
Array
arrays.shuffle(array) ⇒ Shuffles the elements of the specified array.
See knuth-shuffle.
Kind: instance method of Arrays
Returns: Array
- A new Array instance
Access: public
Param | Type | Description |
---|---|---|
array | Array |
The array to shuffle |