Loop iteration (length comparison variations)

Benchmark created on


Preparation HTML

<script>
  var list = [
      "oranges",
      "apples",
      "tangerines",
      "watermelon",
      "nectarines",
      "peaches",
      "strawberries",
      "oranges",
      "apples",
      "tangerines",
      "watermelon",
      "nectarines",
      "peaches",
      "strawberries",
      "oranges",
      "apples",
      "tangerines",
      "watermelon",
      "nectarines",
      "peaches",
      "strawberries",
      "oranges",
      "apples",
      "tangerines",
      "watermelon",
      "nectarines",
      "peaches",
      "strawberries"
  ];
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Using list.length
for (var i = 0; i < list.length; i++) {
    var fruit = list[i];
}
ready
Using static len
for (var i = 0, len = list.length; i < len; i++) {
    var fruit = list[i];
}
ready

Revisions

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