me.utils.array

a collection of array utility functions

Methods

static random(arr) → {any}

return a random array element

Parameters:
Name Type Description
arr Array

array to pick a element

Returns:
any -

random member of array

Example
// Select a random array element
var arr = [ "foo", "bar", "baz" ];
console.log(me.utils.array.random(arr));

static remove(arr, object) → {Array}

Remove the specified object from the given Array

Parameters:
Name Type Description
arr Array

array from which to remove an object

object Object

to be removed

Returns:
Array -

the modified Array

static weightedRandom(arr) → {any}

return a weighted random array element, favoring the earlier entries

Parameters:
Name Type Description
arr Array

array to pick a element

Returns:
any -

random member of array