[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set [Back]  [Original]

TypedArray.prototype.set() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

TypedArray.prototype.set()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.

set() .

In this article

// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(8);
const uint8 = new Uint8Array(buffer);

// Copy the values into the array starting at index 3
uint8.set([1, 2, 3], 3);

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

js
typedarr.set(array[, offset])
typedarr.set(typedarray[, offset])

array

. , + , .

typedarray

, ArrayBuffer ; (destination) .

offset Optional

array . , 0 (, array 0 ).

RangeError

offset .

set()

js
var buffer = new ArrayBuffer(8);
var uint8 = new Uint8Array(buffer);

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

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

Specification
ECMAScript 2027 LanguageSpecification
# sec-%typedarray%.prototype.set


Web Proxy Viewer  |  New URL  |  Original Page