Map.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 Juli 2015.
Die entries()-Methode von Map-Instanzen gibt ein neues map iterator Objekt zurück, das die [key, value]-Paare für jedes Element in dieser Map in der Einfügereihenfolge enthält.
Probieren Sie es aus
const map = new Map(); map.set("0", "foo"); map.set(1, "bar"); const iterator = map.entries(); console.log(iterator.next().value); // Expected output: Array ["0", "foo"] console.log(iterator.next().value); // Expected output: Array [1, "bar"] Syntax
js
entries() Parameter
Keine.
Rückgabewert
Ein neues iterierbares Iterator-Objekt.
Beispiele
>Verwendung von entries()
js
const myMap = new Map(); myMap.set("0", "foo"); myMap.set(1, "bar"); myMap.set({}, "baz"); const mapIter = myMap.entries(); console.log(mapIter.next().value); // ["0", "foo"] console.log(mapIter.next().value); // [1, "bar"] console.log(mapIter.next().value); // [Object, "baz"] Spezifikationen
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-map.prototype.entries> |