object vs array perf

Benchmark created on


Preparation HTML

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

Test runner

Ready to run.

Testing in
TestOps/sec
array access
for (var i = 10000; i--;)
var v = arr[2];
ready
obj 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.