Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

TypedArray.prototype.fill()

この記事は編集レビューを必要としています。ぜひご協力ください

概要

fill()メソッドは、typed array中の開始インデックスから終了インデックスまでの全ての要素を固定値で設定します。このメソッドのアルゴリズムはArray.prototype.fill()と同じです。ここで、TypedArraytyped array typesのいずれかを指します。

構文

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

引数

value
typed arrayを埋める値
start
オプション。開始インデックス。デフォルトは0です。
end
オプション。終了インデックス。デフォルトはthis.lengthです。

説明

設定される要素の範囲は[start, end)です (endは含まれません)。

fill メソッドは最大三つの引数 valuestartend をとります。 startend はオプションの引数で、デフォルト値はそれぞれ 0this オブジェクトの length です。

start が負の値の場合、length+start として扱われます (length は配列の長さ)。end が負の値の場合、length+end として扱われます。

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]

仕様

仕様 策定状況 コメント
ECMAScript 2015 (6th Edition, ECMA-262)
TypedArray.prototype.fill の定義
標準 初期定義。
ECMAScript 2017 Draft (ECMA-262)
TypedArray.prototype.fill の定義
ドラフト  

ブラウザ実装状況

機能 Chrome Firefox (Gecko) Internet Explorer Opera Safari
基本サポート 45 37 (37) 未サポート 32 未サポート
機能 Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
基本サポート 未サポート 未サポート 37 (37) 未サポート 未サポート 未サポート

関連情報

ドキュメントのタグと貢献者

 このページの貢献者: taiyaki32p, shide55
 最終更新者: taiyaki32p,