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

TypedArray.prototype.copyWithin() - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

TypedArray.prototype.copyWithin()

Baseline

20169

copyWithin() TypedArray Array.prototype.copyWithin()

const uint8 = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);

// 
uint8.copyWithin(3, 1, 3);

console.log(uint8);
// : Uint8Array [1, 2, 3, 2, 3, 6, 7, 8]

js
copyWithin(target, start)
copyWithin(target, start, end)

target

start start end

start

end

copyWithin() end

Array.prototype.copyWithin()

copyWithin()

js
const buffer = new ArrayBuffer(8);
const uint8 = new Uint8Array(buffer);
uint8.set([1, 2, 3]);
console.log(uint8); // Uint8Array [ 1, 2, 3, 0, 0, 0, 0, 0 ]
uint8.copyWithin(3, 0, 3);
console.log(uint8); // Uint8Array [ 1, 2, 3, 1, 2, 3, 0, 0 ]

ECMAScript 2027 LanguageSpecification
# sec-%typedarray%.prototype.copywithin


Web Proxy Viewer  |  New URL  |  Original Page