Checking what is faster - map or for

Benchmark created on


Setup

let data = [];

for (let i = 0; i < 1000000; i++){
	data.push(i);
}

Test runner

Ready to run.

Testing in
TestOps/sec
For loop
let sum = 0;

for (let k = 0; k < data.length; k++){
	let v = data[k];
	sum += v;	
}
ready
Map
let sum = 0;

data.map((k,v)=>{ sum += v;});
ready

Revisions

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