Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
for of loop vs. .map
(version: 1)
Comparing performance of:
.map vs for loop
Created:
one year ago
by:
Registered User
Jump to the latest result
Script Preparation code:
// Create sample data var array = [1,2,3,4,5,6,7,8,9,0]; var manipulateFn = num => { return num * 2 * 3; }
Tests:
.map
var newArray = array.map( i => manipulateFn(i));
for loop
var newArray = []; for (const item of array) { newArray.push(manipulateFn(item)); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
.map
for loop
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; ) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.61 Chrome/126.0.6478.61 Not/A)Brand/8 Safari/537.36
Browser/OS:
Chrome 126 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
.map
8687036.0 Ops/sec
for loop
7652267.5 Ops/sec
Related benchmarks:
For Each Vs Map Example Medium
For Each Vs Map Example Medium 2
For Each Vs Map Example Medium1
For Each Vs Map
comparing for vs map vs forEach methods
for loop vs. .map
for loop vs. .map [2]
for loop vs. .map but fast
for loop vs. .map anon
Comments
Confirm delete:
Do you really want to delete benchmark?