在线文档教程

array.values

array.values

values()方法返回一个新的 Array Iterator 对象,该对象包含数组每个索引的值。

var a = ['w', 'y', 'k', 'o', 'p']; var iterator = a.values( console.log(iterator.next().value // w console.log(iterator.next().value // y console.log(iterator.next().value // k console.log(iterator.next().value // o console.log(iterator.next().value // p

语法

arr.values()

返回值

一个新的Array迭代器对象。

示例

使用 for...of 循环进行迭代

var arr = ['w', 'y', 'k', 'o', 'p']; var iterator = arr.values( for (let letter of iterator) { console.log(letter }

规范

SpecificationStatusComment
ECMAScript 2015 (6th Edition, ECMA-262)The definition of 'Array.prototype.values' in that specification.StandardInitial definition.
ECMAScript Latest Draft (ECMA-262)The definition of 'Array.prototype.values' in that specification.Living Standard

浏览器兼容性

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic SupportNo(Yes)No1NoNo9

FeatureAndroidChrome for AndroidEdge mobileFirefox for AndroidIE mobileOpera AndroidiOS Safari
Basic SupportNoNo(Yes)NoNoNoNo