1. Array.prototype.slice.call() 转数组再遍历
var a= document.querySelectorAll('div'); var arr = Array.prototype.slice.call(a); console.log(arr);
2.
var a= document.querySelectorAll('div'); var arr = Array.from(a); arr.forEach(function(i){
console.log(i);
})
3.for of
let elements = document.querySelectorAll('div'); for (let element of elements) { console.log(element.tagName); }