dots vs brackets

Benchmark created by Dan W on


Setup

var MyObject = function(){
    }
    
    var o = new MyObject();
    var p = MyObject.prototype;

Test runner

Ready to run.

Testing in
TestOps/sec
dot write
p.x = 100;
p.y = 10.5
p.s = "string";
ready
brackets write
o['x'] = 100;
o['y'] = 10.5
o['s'] = "string";
ready
dot read
var sum = o.x + o.y;
ready
brackets read
var sum = o['x'] + o['y'];
ready

Revisions

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

  • Revision 1: published by Dan W on