GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • MDN
  • HTML: Markup language
  • Elements
  • Global attributes
  • Attributes
  • See all…
  • Responsive images
  • HTML cheatsheet
  • Date & time formats
  • See all…
  • SVG
  • MathML
  • XML
  • CSS: Styling language

This view

  • Original page
  • New address

GeezerVison is showing developer.mozilla.org — Map.prototype.values() - JavaScript | MDN

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Map.prototype.values()

基线
广泛可用

自 2015年7月 起,此特性已在主流浏览器中得到支持,可在大多数设备和浏览器版本中正常使用。

  • 查看完整兼容性
  • 了解更多

Map 实例的 values() 方法返回一个新的 map 迭代器对象,该对象包含此 map 中每个元素的值,按插入顺序排列。

尝试一下

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"

语法

js
values()

参数

无。

返回值

一个新的可迭代迭代器对象。

示例

使用 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"

规范

规范
ECMAScript® 2027 Language Specification
# sec-map.prototype.values

浏览器兼容性

参见

  • Map.prototype.entries()
  • Map.prototype.keys()

帮助改进 MDN

了解如何参与贡献

此页面最后更新于 2026年10月10日,由 MDN 贡献者更新。

在 GitHub 上查看此页面 • 报告此内容的问题
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.