Array.prototype.map vs Array.prototype.forEach

Edit on GitHub

Setup

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

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

Tests

  • Array#map

    data.map(function(element, index) {
      element === data[index]
    });
  • Array#forEach

    data.forEach(function(element, index) {
      element === data[index]
    });