Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
String() vs .toString() vs String Literal vs String concat
(version: 1)
Comparing performance of:
String() vs .toString() vs String Literal vs String Concat
Created:
11 months ago
by:
Guest
Jump to the latest result
Tests:
String()
let num = 500; let nums = []; for(let i = 0; i < 100; ++i) { nums.push(String(num)); }
.toString()
let num = 500; let nums = []; for(let i = 0; i < 100; ++i) { nums.push(num.toString()); }
String Literal
let num = 500; let nums = []; for(let i = 0; i < 100; ++i) { nums.push(`${num}`); }
String Concat
let num = 500; let nums = []; for(let i = 0; i < 100; ++i) { nums.push(num + ''); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
String()
.toString()
String Literal
String Concat
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
5 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser/OS:
Chrome 142 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
String()
3944864.5 Ops/sec
.toString()
1021403.5 Ops/sec
String Literal
3967012.2 Ops/sec
String Concat
3925930.5 Ops/sec
Related benchmarks:
String() vs .toString() vs string concatenation
Number to String: toString() vs String() vs + ""
String() vs .toString() vs ("" +)
toString vs String Concatenation
String() vs .toString() vs concat vs template
String() vs .toString() vs plus empty string
String() vs .toString() vs adding empty string
String() vs .toString() vs +""
string concat vs .toString()
Comments
Confirm delete:
Do you really want to delete benchmark?