for-loop vs. for-in-loop (v6)

Revision 6 of this benchmark created on


Description

Dramatically simplified for strings only and only two test cases; trying to get rid of variables and simulate Only the bare difference between the for and for in method.

Setup

var arr = ["foo", "bar", "baz", "derp", "herp", "foo"];

Test runner

Ready to run.

Testing in
TestOps/sec
for
for (var i = 0, len = arr.length; i < len; i++) {
 arr[i];
}
ready
for-in
for (var a in arr) {
 arr[a];
}
ready
for ++i
for (var i = -1, len = arr.length; ++i < len;) {
 arr[i];
}
ready

Revisions

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