object vs array perf (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script>
  var arr = [1, 2, 3];
  var obj = {'foo': 1, 'bar': 2, 'baz': 3};
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
array access
for (var i = 10000; i--;)
var v = arr[2];
ready
obj bracket access
for (var i = 10000; i--;)
var v = obj['foo'];
ready
obj dot access
for (var i = 10000; i--;)
var v = obj.foo;
ready

Revisions

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