Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
for loop vs. .map [5]
(version: 1)
Comparing performance of:
.map vs for loop
Created:
2 months ago
by:
Guest
Jump to the latest result
Script Preparation code:
// Create sample data const N = 1_000_000; var theArr = Array.from({ length: N }, (_, i) => i); var theArr2 = []
Tests:
.map
for (let i=0;i<theArr.length; i++) { theArr2.push(theArr[i]+2); }
for loop
theArr2 = theArr.map( (theEl)=>theEl+1 ).map( (theEl)=>theEl+1 );
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:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?