speed

Benchmark created on


Setup

const testData = [
	{name: 'test'},
	{name: 'test'},
	{name: 'test'},
	{name: 'test'},
	{name: 'test'},
	{name: 'test'},
];

const point = {x: 0, y: 0};

Test runner

Ready to run.

Testing in
TestOps/sec
map
const newArr =  testData.map((item) => {
	item.point = point;
	return item;
});
ready
forEach
testData.forEach((item) => {
	item.point = point;
})
ready
for
for(let i = 0; i < testData.length; i++) {
	testData[i].point = point;
}
ready
for...of
for(const item of testData) {
	item.point = point;
}
ready
for reverse
for(let i = testData.length - 1; i >= 0; i--) {
	testData[i].point = point;
}
ready

Revisions

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