foreach vs map

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
foreach
arr.forEach((num, index) => {
    return arr[index] = num * 2;
});
ready
map
let doubled = arr.map(num => {
    return num * 2;
});
ready

Revisions

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