Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Capitalize
(version: 0)
Comparing performance of:
1 vs 2 vs 3 vs 4 vs 5
Created:
8 years ago
by:
Guest
Jump to the latest result
Tests:
1
function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); } capitalizeFirstLetter('string');
2
function capitalizeFirstLetter(string) { return string.replace(/^./, string[0].toUpperCase()); } capitalizeFirstLetter('string');
3
function capitalizeFirstLetter(string) { return string[0].toUpperCase() + string.slice(1); } capitalizeFirstLetter('string');
4
String.prototype.capitalizeFirstLetter = function() { return this.charAt(0).toUpperCase() + this.slice(1); } 'string'.capitalizeFirstLetter();
5
function capitalizeFirstLetter(s) { return s[0].toUpperCase() + s.substr(1); } capitalizeFirstLetter('string');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
1
2
3
4
5
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
6 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.939 YaBrowser/24.1.1.939 (beta) Yowser/2.5 Safari/537.36
Browser/OS:
Yandex Browser 24 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
1
60037908.0 Ops/sec
2
14020842.0 Ops/sec
3
61089764.0 Ops/sec
4
7230513.5 Ops/sec
5
60697776.0 Ops/sec
Related benchmarks:
Capitalize
Capitalize
capitalize_1
lodash vs own capitalize function
Comments
Confirm delete:
Do you really want to delete benchmark?