Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Template literals vs String concat vs Array.join()
(version: 2)
Comparing performance of:
Template Literal vs String Concatenation vs Array.join()
Created:
one year ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const slug = '1234567890';
Tests:
Template Literal
for (let i = 0; i < 1000000; i++) { const url = `/${slug}.html`; }
String Concatenation
for (let i = 0; i < 1000000; i++) { const url = '/' + slug + '.html'; }
Array.join()
for (let i = 0; i < 1000000; i++) { const url = ['/', slug, '.html'].join(''); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Template Literal
String Concatenation
Array.join()
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
12 days ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.0.0
Browser/OS:
Chrome 147 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Template Literal
459.0 Ops/sec
String Concatenation
1025.0 Ops/sec
Array.join()
22.7 Ops/sec
Related benchmarks:
Template strings vs. String.concat
Native JS: concatenate string with + vs template literals vs String.concat my
Native JS: concatenate string with + vs template literals vs String.concat_0
concatenation vs template literal
toString vs string template literal
toString vs string template literal vs String()
number to string: template literal vs toString vs string literal concat vs string constructor
String vs. Template Literal
String vs template string
Comments
Confirm delete:
Do you really want to delete benchmark?