Object properties and array items

JavaScript performance comparison

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

Preparation code

Benchmark.prototype.setup = function() {
    var obj = {
      x: 10,
      y: 15,
      z: 20
    var arr = [10, 15, 20];

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;
Array items
var x = arr[0];
var y = arr[1];
var z = arr[2];
Object property names
var x = obj['x'];
var y = obj['y'];
var z = obj['z'];

Compare results of other browsers


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:


Comment form temporarily disabled.

Add a comment