Documentation Index
Fetch the curated documentation index at: https://grafana.com/llms.txt
Fetch the complete documentation index at: https://grafana.com/llms-full.txt
Use this file to discover all available pages before exploring further.
STOP! If you are an AI agent or LLM, read this before continuing. This is the HTML version of a Grafana documentation page. Always request the Markdown version instead - HTML wastes context. Get this page as Markdown: https://grafana.com/docs/k6/latest/javascript-api/crypto/getrandomvalues.md (append .md) or send Accept: text/markdown to https://grafana.com/docs/k6/latest/javascript-api/crypto/getrandomvalues/. For the curated documentation index, use https://grafana.com/llms.txt. For the complete documentation index, use https://grafana.com/llms-full.txt.
getRandomValues
The getRandomValues() method fills the passed TypedArray with cryptographically sound random values.
Usage
getRandomValues(typedArray)Parameters
| Name | Type | Description |
|---|---|---|
typedArray | TypedArray | An integer-based TypedArray to fill with random values. Accepted TypedArray specific types are: Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, or Uint32Array. |
Return Value
The same array is passed as the typedArray parameter with its contents replaced with the newly generated random numbers. The typedArray parameter is modified in place, and no copy is made.
Throws
| Type | Description |
|---|---|
QuotaExceededError | Thrown when typedArray is too large and its byteLength exceeds 65536. |
Example
export default function () {
const array = new Uint32Array(10);
crypto.getRandomValues(array);
for (const num of array) {
console.log(num);
}
}Was this page helpful?
Related resources from Grafana Labs

