Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Array.prototype.entries()

entries()方法回傳一個包含陣列所有索引之鍵值組的新陣列迭代器(Array Iterator)物件。

語法

arr.entries()

範例

var arr = ['a', 'b', 'c'];
var eArr = arr.entries();

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

同上,使用 for…of 迴圈:

var arr = ['a', 'b', 'c'];
var eArr = arr.entries();

for (let e of eArr) {
  console.log(e);
}

規格

規格 狀態 備註
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Array.prototype.entries' in that specification.
Standard 首次定義。
ECMAScript 2017 Draft (ECMA-262)
The definition of 'Array.prototype.entries' in that specification.
Draft  

瀏覽器相容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 38 28 (28) No support 25 7.1
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support No support No support 28.0 (28) No support No support 8.0

請參閱

文件標籤與貢獻者

 此頁面的貢獻者: tericky
 最近更新: tericky,