TypedArray.prototype.entries()
entries()
メソッドは、配列内の各インデックスのキーと値のペアを含む新しい配列イテレーターオブジェクトを返します。
試してみましょう
構文
entries()
返値
新しい配列イテレーターオブジェクトです。
例
for...of ループを使用した反復処理
const array = new Uint8Array([10, 20, 30, 40, 50]);
const arrayEntries = arr.entries();
for (const element of arrayEntries) {
console.log(element);
}
他の反復処理
const array = new Uint8Array([10, 20, 30, 40, 50]);
const arrayEntries = arr.entries();
console.log(arrayEntries.next().value); // [0, 10]
console.log(arrayEntries.next().value); // [1, 20]
console.log(arrayEntries.next().value); // [2, 30]
console.log(arrayEntries.next().value); // [3, 40]
console.log(arrayEntries.next().value); // [4, 50]
仕様書
Specification |
---|
ECMAScript Language Specification # sec-%typedarray%.prototype.entries |
ブラウザーの互換性
BCD tables only load in the browser