Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
concat vs template
(version: 0)
Comparing performance of:
concat vs template
Created:
4 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var variable = 19203142354657687980n; var text = 'hi my bigint is';
Tests:
concat
console.log(text + ' ' + variable);
template
console.log(`${text} ${variable}`);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
concat
template
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
concat
621102.9 Ops/sec
template
617757.6 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down what is tested on the provided JSON for the `concat vs template` benchmark. **What is being tested?** The benchmark compares the performance of two ways to concatenate (join) strings in JavaScript: 1. **Concatenation using the `+` operator**: This method uses string interpolation, where a variable `text` and a constant value `variable` are concatenated with spaces in between. 2. **Template literals**: This method uses template literals, which allow you to embed expressions inside string literals. **Options being compared** The two options being compared are: * **Concatenation using the `+` operator** * **Template literals** **Pros and Cons of each approach** **Concatenation using the `+` operator:** Pros: * Wide support across browsers * Easy to read and write Cons: * Can be slower than template literals due to string creation and concatenation * May have performance issues with large strings or frequent concatenations **Template literals:** Pros: * Can be faster than concatenation using the `+` operator due to optimized string creation * Allows for more expressive and readable code Cons: * Less supported across older browsers (e.g., IE 11) * May require additional parsing steps in some browsers **Library usage** There is no library explicitly mentioned, but template literals are a built-in feature of JavaScript. **Special JS features or syntax** Template literals use the backtick (`) character to enclose the string expression. This allows for embedding expressions inside string literals using the `${}` syntax. **Other alternatives** Alternative ways to concatenate strings in JavaScript include: * `+` operator with string concatenation (as shown in the benchmark) * String methods like `toString()`, `concat()`, or `join()`
Related benchmarks:
Template strings vs. String.concat
string concatenation vs template
Concatenation vs Template String
Native JS2: concatenate string with + vs template literals vs String.concat
Comments
Confirm delete:
Do you really want to delete benchmark?