Map.prototype.values()

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 values()-Methode von Map-Instanzen gibt ein neues Map-Iterator-Objekt zurück, das die Werte jedes Elements in dieser Map in der Reihenfolge ihrer Einfügung enthält.

Probieren Sie es aus

const map1 = new Map();

map1.set("0", "foo");
map1.set(1, "bar");

const iterator1 = map1.values();

console.log(iterator1.next().value);
// Expected output: "foo"

console.log(iterator1.next().value);
// Expected output: "bar"

Syntax

js
values()

Parameter

Keine.

Rückgabewert

Beispiele

Verwendung von values()

js
const myMap = new Map();
myMap.set("0", "foo");
myMap.set(1, "bar");
myMap.set({}, "baz");

const mapIter = myMap.values();

console.log(mapIter.next().value); // "foo"
console.log(mapIter.next().value); // "bar"
console.log(mapIter.next().value); // "baz"

Spezifikationen

Specification
ECMAScript® 2025 Language Specification
# sec-map.prototype.values

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
values

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Siehe auch