Primitive value string vs Wrapper Object String - charAt() (v5)

Revision 5 of this benchmark created by Trevor Norris on


Preparation HTML

str1.charAt(0) = <div id="id1"></div><br>
str2.charAt(0) = <div id="id2"></div>

Setup

var str1 = "Hello";
    var str2 = new String("Hello");
    
    var i = "(idle)",
        k = "(idle)";

Teardown


    var x = document.getElementById("id1"); x.innerHTML = i;
    var y = document.getElementById("id2"); y.innerHTML = k;
  

Test runner

Ready to run.

Testing in
TestOps/sec
Primitive value string str1.charAt(0)
i = str1.charAt(0);
ready
Wrapper object string str2["0"]
k = str2.charAt(0);
ready

Revisions

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