in versus bracket versus dot

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var obj = {foo : 1, bar: 2, baz: 3};
};
</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
in true
'foo' in obj
pending…
in false
'x' in obj
pending…
bracket true
obj['foo']
pending…
bracket false
obj['x']
pending…
dot true
obj.foo
pending…
dot false
obj.x
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