Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for..in vs for..of vs classic for
Testing the difference between for..in vs for..of vs classic for
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0
Browser:
Firefox 135
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
classic for
52.3 Ops/sec
for..of
55.1 Ops/sec
for..in
12.0 Ops/sec
HTML Preparation code:
<div id='test'></div>
Tests:
classic for
const arr = Array.from(Array(1000000).keys()); const odds = [] for(i=0; i<arr.length; i++){ const value = arr[i]; odds[i] = (value%2 === 0) ? 'odd' : 'even'; }
for..of
const arr = Array.from(Array(1000000).keys()); const odds = [] for (const value of arr) { odds[value] = (value%2 === 0) ? 'odd' : 'even'; }
for..in
const arr = Array.from(Array(1000000).keys()); const odds = [] for (const value in arr) { odds[value] = (value%2 === 0) ? 'odd' : 'even'; }