.(dot) vs [](square bracket) (v13)

Revision 13 of this benchmark created on


Preparation HTML

<script>
var foo = {
    path: {
        to: {
            node: {
                value: 'value'
            }
        }
    }
};
var bar = {
    'path.to.node.value': 'value'
};
var baz = {
    'this.is.long.path.name.foo.bar.baz.path.to.node.value': 'value'
};
var qux = {
    'value': 'value'
};
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
.
var a = window.document;
ready
[]
var a = window["document"];
ready
foo
var a = foo.path.to.node.value;
ready
bar
var a = bar['path.to.node.value'];
ready
baz
var a = baz['this.is.long.path.name.foo.bar.baz.path.to.node.value'];
ready
qux
var a = qux['value'];
ready
foo[]
var a = foo['path']['to']['node']['value'];
ready
foo[] check
var a = ( foo['path'] && foo['path']['to'] && foo['path']['to']['node'] && foo['path']['to']['node']['value'] );
ready
foo[] check2
var a = (((((foo||0).path||0).to||0).node||0).value );
 
ready

Revisions

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

  • Revision 1: published by JavaScript Nazi on
  • Revision 2: published by Kyle Simpson on
  • Revision 5: published by Michael Norman on
  • Revision 6: published by blocks-vs-functions on
  • Revision 7: published on
  • Revision 8: published by mah0x211 on
  • Revision 9: published by mah0x211 on
  • Revision 13: published on
  • Revision 15: published on
  • Revision 18: published by foo on