forEach vs. map

Benchmark created by Rick Hitchcock on


Setup

var array = [ 23, 67, 120, 170, 200, 212, 350 ]

Test runner

Ready to run.

Testing in
TestOps/sec
forEach
array.forEach(function(val, idx) {
  array[idx]= val*0.8;
});
ready
map
array= array.map(function(val) {
  return val*0.8;
});
ready

Revisions

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

  • Revision 1: published by Rick Hitchcock on