crypto.getRandomValues

Generates random values.

Note

The result is generated using the cryptographically secure random number generator.

Syntax

crypto.getRandomValues(typedArray)

Parameters

Return value

The same typed array as the parameter, filled with random values.

Example

crypto.getRandomValues(new Uint8Array(8))
Uint8Array [181, 221, 110, 124, 191, 102, 40, 246]
crypto.getRandomValues(new BigInt64Array(2))
BigInt64Array [1364260839042713042, -2173253636153072395]
crypto.getRandomValues(new Float64Array(8))
TypeError: not an integer array

See also