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/Werte-Paare für jeden Index im typisierten Array enthält. Diese Methode verwendet denselben Algorithmus wie Array.prototype.entries().

Probieren Sie es aus

const uint8 = new Uint8Array([10, 20, 30, 40, 50]);
const eArr = uint8.entries();

eArr.next();
eArr.next();

console.log(eArr.next().value);
// Expected output: Array [2, 30]

Syntax

js
entries()

Parameter

Keine.

Rückgabewert

Beschreibung

Weitere Details finden Sie unter Array.prototype.entries(). Diese Methode ist nicht generisch und kann nur auf 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® 2026 Language Specification
# sec-%typedarray%.prototype.entries

Browser-Kompatibilität

Siehe auch