Object properties and array items

JavaScript performance comparison

Revision 2 of this test case created by Göran Andersson

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var obj = {
      x: 10,
      y: 15,
      z: 20
    };
   
    var arr = [10, 15, 20];
   
};
</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 properties
var x = obj.x;
var y = obj.y;
var z = obj.z;
pending…
Array items
var x = arr[0];
var y = arr[1];
var z = arr[2];
pending…
Object property names
var x = obj['x'];
var y = obj['y'];
var z = obj['z'];
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. Here’s a list of current revisions for this page:

0 comments

Add a comment