Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
String accumulation with forEach vs. map+join
(version: 0)
Comparing performance of:
map+join vs forEach
Created:
5 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var property = "justify-content"; var value = ["space-around", "space-evenly"]; function normalizeDeclaration(property, value) { return property + ":" + value; }
Tests:
map+join
var result = value .map((fallbackValue) => normalizeDeclaration(property, fallbackValue)) .join(";");
forEach
var cssText = ""; value.forEach((fallbackValue) => { cssText += "" + normalizeDeclaration(property, fallbackValue); }); var result = cssText.slice(1);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
map+join
forEach
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:109.0) Gecko/20100101 Firefox/115.0
Browser/OS:
Firefox 115 on Mac OS X 10.13
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
map+join
620464.1 Ops/sec
forEach
6243676.5 Ops/sec
Related benchmarks:
spread vs concat xxx2
spread operator vs concat
unshift vs spread vs concat
concat vs spread cb
Concat vs spread for a single value
Comments
Confirm delete:
Do you really want to delete benchmark?