pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill

7c-4bdf-a490-390a1aebf6dd/airgap.js" >

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

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. It’s been available across browsers since 2016年9月.

fill()TypedArray インスタンスのメソッドで、型付き配列のある範囲のインデックスにあるすべての要素を固定値で埋めます。これは変更された型付き配列を返します。このメソッドのアルゴリズムは Array.prototype.fill() と同じです。

試してみましょう

const uint8 = new Uint8Array([0, 0, 0, 0]);
// 値、開始位置、終了位置
uint8.fill(4, 1, 3);

console.log(uint8);
// 予想される結果: Uint8Array [0, 4, 4, 0]

構文

js
fill(value)
fill(value, start)
fill(value, start, end)

引数

value

型付き配列を埋める値です。

start 省略可

埋まる範囲の開始点を表すゼロ基点のインデックスで、整数に変換されます

end 省略可

埋まる範囲の終了点を表すゼロ基点のインデックスで、整数に変換されますfill()end の手前までを埋めます。

返値

変更された配列です。

解説

詳細については、 Array.prototype.fill() をご覧ください。このメソッドは汎用的ではなく、型付き配列インスタンスに対してのみ呼び出すことができます。

fill() の使用

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 Language Specification
# sec-%typedarray%.prototype.fill

ブラウザーの互換性

関連情報

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy