Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Javascript strings 'concat()' vs '+' vs `${}` when appending mulitple strings
(version: 1)
Benchmark.js
Comparing performance of:
concat() vs plus_operator vs Mix vs Formatstring
Created:
8 days ago
by:
Guest
Go to the latest result
Script Preparation code:
let str = "Hello";
Tests:
concat()
let combinedConcat = "Start"; for(i = 0; i < 1000; i++) { combinedConcat = combinedConcat.concat(" ", str); } console.log(combinedConcat);
plus_operator
let combinedPlus = "Start"; for(i = 0; i < 1000; i++) { combinedPlus += " " + str; } console.log(combinedPlus);
Mix
let combinedConcatPlus = "Start"; for(i = 0; i < 1000; i++) { combinedConcatPlus = combinedConcatPlus.concat(" " + str); } console.log(combinedConcatPlus);
Formatstring
let combinedFormat = "Start"; for(i = 0; i < 1000; i++) { combinedFormat = `${combinedFormat} ${str}` } console.log(combinedFormat);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
concat()
plus_operator
Mix
Formatstring
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
7 days ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:155.0) Gecko/20100101 Firefox/155.0
Browser/OS:
Firefox 155 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
concat()
26K/s
plus_operator
17K/s
Formatstring
15K/s
Mix
11K/s
View exact numbers
Test name
Executions per second
✓
concat()
26,309 Ops/sec
plus_operator
17,400 Ops/sec
Formatstring
15,473 Ops/sec
Mix
11,122 Ops/sec
Related benchmarks
Native JS: concatenate string with + vs template literals vs String.concat
Native JS: string plus VS template string!
Comments
Confirm delete:
Do you really want to delete benchmark?