values()
方法返回一个新的 Array Iterator
对象,该对象包含数组每个索引的值
arr.values()
使用 for...of
循环进行迭代let arr = ['w', 'y', 'k', 'o', 'p'];
let eArr = arr.values();
// 您的浏览器必须支持 for..of 循环
// 以及 let —— 将变量作用域限定在 for 循环中
for (let letter of eArr) {
console.log(letter);
}
let arr = ['w', 'y', 'k', 'o', 'p'];
let eArr = arr.values();
console.log(eArr.next().value); // w
console.log(eArr.next().value); // y
console.log(eArr.next().value); // k
console.log(eArr.next().value); // o
console.log(eArr.next().value); // p
规范名称 | 规范状态 | 备注 |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) Array.prototype.values |
Standard | 首次定义 |
ECMAScript Latest Draft (ECMA-262) Array.prototype.values |
Draft |
Desktop | Mobile | Server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
values | Chrome Full support 66 | Edge Full support 12 | Firefox Full support 60 | IE No support No | Opera Full support 53 | Safari Full support 9 | WebView Android Full support 66 | Chrome Android Full support 66 | Edge Mobile Full support Yes | Firefox Android Full support 60 | Opera Android Full support 53 | Safari iOS Full support 9 | Samsung Internet Android No support No | nodejs
Full support
10.9.0
|