Object vs Literal when performing object operations

JavaScript performance comparison

Test case created by Josh

Info

The lesson here is to always use the object literal notation. But you already knew that.

Preparation code

<script>
  var literal = [],
      arr = new Array();
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Object
arr.forEach(function(el) {});
pending…
Literal
literal.forEach(function(el) {});
pending…

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

Compare results of other browsers

0 comments

Add a comment