MCPcopy Index your code
hub / github.com/phaserjs/phaser / GetRandom

Function GetRandom

src/utils/array/GetRandom.js:23–31  ·  view source on GitHub ↗
(array, startIndex, length)

Source from the content-addressed store, hash-verified

21 * @return {T} A random element from the array, or `null` if no element could be found in the range given.
22 */
23var GetRandom = function (array, startIndex, length)
24{
25 if (startIndex === undefined) { startIndex = 0; }
26 if (length === undefined) { length = array.length; }
27
28 var randomIndex = startIndex + Math.floor(Math.random() * (length - startIndex));
29
30 return (array[randomIndex] === undefined) ? null : array[randomIndex];
31};
32
33module.exports = GetRandom;

Callers 3

RandomizeFunction · 0.85
ParticleEmitter.jsFile · 0.85
GetRandom.test.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…