UNB/ CS/ David Bremner/ teaching/ cs2613/ books/ mdn/ Reference/ Global Objects/ TypedArray/ TypedArray.prototype.set()

The set() method of TypedArray instances stores multiple values in the typed array, reading input values from a specified array.

Syntax

set(array)
set(array, targetOffset)

set(typedarray)
set(typedarray, targetOffset)

Parameters

Return value

None (undefined).

Exceptions

Examples

Using set()

const buffer = new ArrayBuffer(8);
const uint8 = new Uint8Array(buffer);

uint8.set([1, 2, 3], 3);

console.log(uint8); // Uint8Array [ 0, 0, 0, 1, 2, 3, 0, 0 ]

Specifications

Browser compatibility

See also