JS Built-ins
cryptobeginner

crypto β€” getRandomValues returns same typed array

πŸ“– Usage Example
const arr = new Uint8Array(4)
crypto.getRandomValues(arr)
arr  // β†’ Uint8Array with random bytes

crypto.getRandomValues() fills a typed array with cryptographically secure random bytes.

crypto.getRandomValues()

crypto.getRandomValues(typedArray) fills the given typed array with cryptographically strong random values and returns the same typed array object.

Challenge: Verify that getRandomValues returns the same array reference that was passed in.

πŸ’‘ Hints (1)
  • β€’ getRandomValues mutates the input array and also returns it