@ishoa/array-helpers

1.1.0 • Public • Published

Array-Helper-Functions

Useful Array functions not built into the Javascript Array Object.

Functions

erase(array, item)

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

forEachReverse(array, funct)

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

random(array)*

Get a random element from the array

shuffle(array)

Randomly shuffle the elements in the Array

clone(array)Array

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

erase(array, item)


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

Param Type Description
array Array Array 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

Param Type Description
array Array The Array to loop through
funct function Function 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

Param Type Description
array Array Array to get the random element from

shuffle(array)


Randomly shuffle the elements in the Array

Param Type Description
array Array Array 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

Param Type Description
array Array Array you want to copy

Example

- let newArray = array.clone();

Readme

Keywords

Package Sidebar

Install

npm i @ishoa/array-helpers

Weekly Downloads

3

Version

1.1.0

License

MIT

Unpacked Size

15.9 kB

Total Files

9

Last publish

Collaborators

  • ishoa