for loop vs Array.prototype.map() (v2)

Revision 2 of this benchmark created on


Setup

var arr = Array.apply(null, Array(10000)).map(Number.prototype.valueOf, 0);
    var newArr = [];
    
    function addOne(val) {
      return val + 1;
    }

Test runner

Ready to run.

Testing in
TestOps/sec
for loop
for (var i = 0, len = arr.length; i < len; i++) {
  newArr.push(addOne(arr[i]));
}
ready
map
newArr = arr.map(addOne)
ready

Revisions

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