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

TypedArray.prototype.fill() - 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.fill()

Baseline Widely available

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

fill() . fill() Array.prototype.fill() . TypedArray typed array types .

In this article

const uint8 = new Uint8Array([0, 0, 0, 0]);
// Value, start position, end position
uint8.fill(4, 1, 3);

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

js
typedarray.fill(value[, start = 0[, end = this.length]])

value

.

start

. . 0.

end

. ( . , end -1 .). this.length( ).

start end .

fill value, start and 3 . start end 0 .

start , start , end , end .

js
new Uint8Array([1, 2, 3]).fill(4); // Uint8Array [4, 4, 4]
new Uint8Array([1, 2, 3]).fill(4, 1); // Uint8Array [1, 4, 4]
new Uint8Array([1, 2, 3]).fill(4, 1, 2); // Uint8Array [1, 4, 3]
new Uint8Array([1, 2, 3]).fill(4, 1, 1); // Uint8Array [1, 2, 3]
new Uint8Array([1, 2, 3]).fill(4, -3, -2); // Uint8Array [4, 2, 3]

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


Web Proxy Viewer  |  New URL  |  Original Page