ArrayUtils.getRandomItem()

<static> getRandomItem(objects, startIndex, length) → {object}

Fetch a random entry from the given array.

Will return null if there are no array items that fall within the specified range
or if there is no item for the randomly chosen index.

Parameters
Name Type Description
objects Array.<any>

An array of objects.

startIndex integer

Optional offset off the front of the array. Default value is 0, or the beginning of the array.

length integer

Optional restriction on the number of values you want to randomly select from.

Returns
object -

The random object that was selected.

Source code: utils/ArrayUtils.js (Line 27)
doc_phaser
2017-02-14 10:36:17
Comments
Leave a Comment

Please login to continue.