Test name | Executions per second |
---|---|
querySelectorAll foreach | 647421.9 Ops/sec |
getElementsByClassName [].forEach.call() | 923590.5 Ops/sec |
Array.prototype | 906438.9 Ops/sec |
Array.from | 470017.9 Ops/sec |
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
var test = document.querySelectorAll(".test");
test.forEach(el => {
var t = el;
});
var test = document.getElementsByClassName("test");
[].forEach.call(test, el => {
var t = el;
});
var test = document.getElementsByClassName("test");
Array.prototype.forEach.call(test, el => {
var t = el;
});
var test = document.querySelectorAll(".test");
Array.from(test).forEach(el => {
var t = el;
});