该方法返回一个迭代协议,允许遍历此对象中包含的所有键/值。该值也是一个Node
对象。
语法
list.entries();
返回值
返回一个 iterator
.
例子
var node = document.createElement("div"); var kid1 = document.createElement("p"); var kid2 = document.createTextNode("hey"); var kid3 = document.createElement("span"); node.appendChild(kid1); node.appendChild(kid2); node.appendChild(kid3); var list = node.childNodes; // 使用 for..of 循环 for(var entry of list.entries()) { console.log(entry); }
结果如下:
Array [ 0, <p> ] Array [ 1, #text "hey" ] Array [ 2, <span> ]
规范
Specification | Status | Comment |
---|---|---|
DOM entries() (as iterable<Node>) |
Living Standard | Initial definition. |
浏览器兼容性
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | ? | 50 (50) | ? | ? | ? |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Andorid |
---|---|---|---|---|---|---|---|---|
Basic support | ? | ? | 50.0 (50) | ? | ? | ? | ? | ? |