For vs For-Of

Edit on GitHub

Setup

var count = 1000 * 1000
var data = [];

do {
  data.push(count);
} while(--count);

Tests

  • For

    var length = data.length;
    for (var index = 0; index < length; index++) {
      var obj = data[index];
      obj == obj;
    }
  • For-Of

    for (var obj of data) {
      obj == obj;
    }