Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
NodeList loop iterator comparison
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:131.0) Gecko/20100101 Firefox/131.0
Browser:
Firefox 131
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
for ... of
54437792.0 Ops/sec
Array.from
19368260.0 Ops/sec
HTML Preparation code:
<ul> </ul> <ol> </ol>
Script Preparation code:
const ul = document.querySelector('ul'); const ol = document.querySelector('ul'); for (let i = 0; i < 1000; i++) { const li = document.createElement('li') li.classList.add(i % 2 === 0 ? 'even' : 'odd') ul.appendChild(document.createElement('li')); ol.appendChild(document.createElement('li')); } var oddListItems = document.querySelectorAll('li.odd'); var anything = [];
Tests:
for ... of
for (const item of oddListItems) { anything.push(item); }
Array.from
Array.from(oddListItems).forEach(item => anything.push(item));