for in or for

JavaScript performance comparison

Test case created by Oliver Caldwell

Preparation code

  var targetObj = new Object();
  for (var i = 0; i < 20; i++) {
   targetObj[i] = 'Filler';

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
for in
for (var i in targetObj) {
for (var i = 0; i < targetObj.length; i++) {

Compare results of other browsers


You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

1 comment

Oliver Caldwell (revision owner) commented :

Wow, Spark is going to get one hell of a speed boost :D

Comment form temporarily disabled.

Add a comment