怎样单独遍历NodeList的键、值和键值对
1. 单独遍历键: NodeList.prototype.keys();
2. 单独遍历值: NodeList.prototype.values();
3. 遍历键值对: NodeList.prototype.entries();
var children = document.body.childNodes; for (var key of children.keys()) { console.log(key); } // 0 // 1 // 2 // ... for (var value of children.values()) { console.log(value); } // #text // <script> // ... for (var entry of children.entries()) { console.log(entry); } // Array [ 0, #text ] // Array [ 1, <script> ] // ...