哪个更好?
1 document.getElementsByClassName('class').__proto__.each = function(el){}
2 Array.prototype.forEach.call(document.getElementsByClassName('class'), function(el){})
答案 0 :(得分:-1)
我测试了这两个代码并且有result at jsperf.com
document.getElementsByClassName('class').__proto__.each = function(el){}
6,447,930±2.61%最快
Array.prototype.forEach.call(document.getElementsByClassName('class'), function(el){})
3,070,270±0.48%慢51%