RingoJS

Module ringo/utils/arrays

Provides utility functions for working with JavaScript Arrays.

Functions


contains (array, val)

Check if an array passed as argument contains a specific value (start from end of array).

Parameters

Array array

the array

Object val

the value to check

Returns

Boolean

true if the value is contained


intersection (array,...)

Retrieve the intersection set of a bunch of arrays.

Parameters

Array array,...

the arrays to intersect

Returns

Array

the intersection set


max (array)

Parameters

Array array

the array

Returns

Number

the maximal element in an array obtained by calling Math.max().


min (array)

Parameters

Array array

the array

Returns

Number

the minimal element in an array obtained by calling Math.min().


peek (array)

Return the last element of the array. This is like pop(), but without modifying the array.

Parameters

Array array

the array

Returns

Object

the last element of the array, or undefined if the array is empty.


remove (array, val)

Remove the first occurrence of the argument value from the array. This method mutates and returns the array on which it is called and does not create a new array instance.

Parameters

Array array

the array

Object val

the value to remove

Returns

Array

the array


union (array1,...)

Retrieve the union set of a bunch of arrays.

Parameters

Array array1,...

the arrays to unify

Returns

Array

the union set