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 July 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 map1 = new Map();
map1.set("0", "foo");
map1.set(1, "bar");
const iterator1 = map1.entries();
console.log(iterator1.next().value);
// Expected output: Array ["0", "foo"]
console.log(iterator1.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® 2025 Language Specification # sec-map.prototype.entries |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
entries |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.