首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

array.entries

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

代码语言:javascript
复制
var a = ['a', 'b', 'c'];
var iterator = a.entries();

console.log(iterator.next().value); // [0, 'a']
console.log(iterator.next().value); // [1, 'b']
console.log(iterator.next().value); // [2, 'c']

语法

代码语言:javascript
复制
a.entries()

返回值

一个新的Array迭代器对象。

示例

使用for…of循环

代码语言:javascript
复制
var a = ['a', 'b', 'c'];
var iterator = a.entries();

for (let e of iterator) {
  console.log(e);
}
// [0, 'a']
// [1, 'b']
// [2, 'c'] 

规范

Specification

Status

Comment

ECMAScript 2015 (6th Edition, ECMA-262)The definition of 'Array.prototype.entries' in that specification.

Standard

Initial definition.

ECMAScript Latest Draft (ECMA-262)The definition of 'Array.prototype.entries' in that specification.

Living Standard

?

浏览器兼容性

Feature

Chrome

Edge

Firefox

Internet Explorer

Opera

Safari

Basic Support

38

(已实现)

28

未实现

25

7.1

Feature

Android

Chrome for Android

Edge mobile

Firefox for Android

IE mobile

Opera Android

iOS Safari

Basic Support

(已实现)

(已实现)

(已实现)

28

未实现

(已实现)

8

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com