for vs map vs map

Edit on GitHub

Setup

var arr = [],
newArr = [];

for( var i = 0; i < 10000;  i++ ) {
   arr[i] = i;
}

Tests

  • for vs map

    for( var l = 0; i < arr.length; i++ ) {
       newArr.push( arr[i] );
    }
  • map

    newArr = arr.map( function(i) {
       return arr[i];
    });