Primitive string vs Wrapper Object String - Properties

Benchmark created on


Preparation HTML

str1 = <div id="id1"></div><br>
str2 = <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 str1 contents from for-in
i = "";
for (var temp in str1) { i += str1[temp]; }
ready
Wrapper Object str2 contents from for-in
k = "";
for (var temp in str2) { k += str2[temp]; }
ready

Revisions

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