TypedArray.prototype.entries()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2016.

Die entries() Methode von TypedArray Instanzen gibt ein neues array iterator Objekt zurück, das die Schlüssel/Wert-Paare für jeden Index im typisierten Array enthält. Diese Methode verwendet denselben Algorithmus wie Array.prototype.entries().

Probieren Sie es aus

Syntax

js
entries()

Parameter

Keine.

Rückgabewert

Beschreibung

Weitere Details finden Sie unter Array.prototype.entries(). Diese Methode ist nicht generisch und kann nur bei typisierten Array-Instanzen aufgerufen werden.

Beispiele

Iteration mit der for...of Schleife

js
const array = new Uint8Array([10, 20, 30, 40, 50]);
const arrayEntries = arr.entries();
for (const element of arrayEntries) {
  console.log(element);
}

Alternative Iteration

js
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]

Spezifikationen

Specification
ECMAScript Language Specification
# sec-%typedarray%.prototype.entries

Browser-Kompatibilität

BCD tables only load in the browser

Siehe auch