map vs for + array.push

Benchmark created on


Preparation HTML


Setup

var data = new Array(100000).fill(0);
var out = [];

Test runner

Ready to run.

Testing in
TestOps/sec
for-i + array.push
var i = 0;
var len = data.length;

for (;i<len;i++) {
	out.push(data[i] + i);
}
ready
for-of + array.push
for (const [i, n] of data.entries()) {
	out.push(n + 1);
}
ready
map
out = data.map(function (n, i) {
	return n + i;
});
ready

Revisions

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