Upcase first character

JavaScript performance comparison

Revision 3 of this test case created by

Preparation code

<script>
  String.prototype.f01 = function(){
   return this.charAt(0).toUpperCase() + this.slice(1);
  };
  String.prototype.f02 = function(){
    return this.replace(/^\w/, function($0) { return $0.toUpperCase();});
  };
</script>
    

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
toUpperCase + slice
var str = 'hello world';
str.f01();
pending…
toUpperCase + replace
var str = 'hello world';
str.f02();
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments