1.1.0 • Published 5 years ago

@ishoa/array-helpers v1.1.0

Weekly downloads
14
License
MIT
Repository
github
Last release
5 years ago

Array-Helper-Functions

Useful Array functions not built into the Javascript Array Object.

Functions

erase(array, item)


Erase a specific item / element /index from the provided Array

ParamTypeDescription
arrayArrayArray to erase the item from
item*The element or item to remove

forEachReverse(array, funct)


Loop through all the elements of an Array backwards and call a function for each index

ParamTypeDescription
arrayArrayThe Array to loop through
functfunctionFunction to call for each index

Example

- forEachReverse([0, 1], (item) => { console.log(item) }); // 1, 0

random(array) ⇒ *


Get a random element from the array

Returns: * - - The random Array index data

ParamTypeDescription
arrayArrayArray to get the random element from

shuffle(array)


Randomly shuffle the elements in the Array

ParamTypeDescription
arrayArrayArray to shuffle the contents of

Example

- shuffle(array);

clone(array) ⇒ Array


Return a copy or clone of the Array that doesn't have reference to the original

Returns: Array - - copied Array

ParamTypeDescription
arrayArrayArray you want to copy

Example

- let newArray = array.clone();
1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago