Class: Random

util.Random

An instance of Random is used to generate random numbers.

Methods

nextBoolean(probabilityOfUndefinedopt) → {boolean|undefined}

Returns a random boolean value.

Parameters:
Name Type Attributes Default Description
probabilityOfUndefined number <optional>
0.0

The probability of returning undefined.

Returns:

A random boolean between origin (inclusive) and bound (exclusive) or undefined.

Type
boolean | undefined

nextDate(maxMillisopt, probabilityOfUndefinedopt) → {Date|undefined}

Returns a random timestamp with optional random offset.

Parameters:
Name Type Attributes Default Description
maxMillis number <optional>
0

The maximum offset in milliseconds.

probabilityOfUndefined number <optional>
0.0

The probability of returning undefined.

Returns:

A random timestamp or undefined.

Type
Date | undefined

nextFloat(originopt, boundopt, probabilityOfUndefinedopt) → {number|undefined}

Returns a random float between origin (inclusive) and bound (exclusive).

Parameters:
Name Type Attributes Default Description
origin number <optional>
0.0

The least value that can be returned.

bound number <optional>
1.0

The upper bound (exclusive) for the returned value.

probabilityOfUndefined number <optional>
0.0

The probability of returning undefined.

Returns:

A random float between origin (inclusive) and bound (exclusive) or undefined.

Type
number | undefined

nextInt(originopt, boundopt, probabilityOfUndefinedopt) → {number|undefined}

Returns a random integer between origin (inclusive) and bound (exclusive).

Parameters:
Name Type Attributes Default Description
origin number <optional>
0

The least value that can be returned.

bound number <optional>
1

The upper bound (exclusive) for the returned value.

probabilityOfUndefined number <optional>
0.0

The probability of returning undefined.

Returns:

A random integer between origin (inclusive) and bound (exclusive) or undefined.

Type
number | undefined

nextValue(valuesopt, probabilityOfUndefinedopt) → {*|undefined}

Returns a random value from an array.

Parameters:
Name Type Attributes Default Description
values Array <optional>
[]

The array of values.

probabilityOfUndefined number <optional>
0.0

The probability of returning undefined.

Returns:

A random value from the array or undefined.

Type
* | undefined