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