literal vs new

Benchmark created on


Preparation HTML

<script>
  var o;
  
  if (!Object.create) {
    Object.create = function (o) {
      var f = function() { };
      f.prototype = o;
      return new f;
    }
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
new
o = new Array;
ready
literal
o = [];
ready
invoke
o = new Array();
ready
create
o = Object.create(Array.prototype);
ready
zero length
o = new Array(0);
ready
without new
o = Array();
ready
new with data
o = new Array("data");
ready
array with data
o = Array("data");
ready
literal with data
o = ["data"];
ready

Revisions

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