Array#forEach vs for i

Edit on GitHub

Faster for or foreach

Setup

Tests

  • Array#forEach

    function() {
      var testArray = [1,2,3,4];
      testArray.forEach(function(node) {
        console.log(node)
      });
    }
  • for i

    function() {
      var testArray = [1,2,3,4];
      for (var i = 0; i < testArray.length; i++) {
        console.log(testArray[i]);
      }
    }