JS array comparison

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Array.push
const arr = [];

for (let i = 0; i < 1000; i++) {
	arr.push('What is faster: an assignment or a function call which looks up the length of an array and performs an assignment?')
}
ready
Index access
const arr = new Array(1000);

for (let i = 0; i < 1000; i++) {
	arr[i] = ('What is faster: an assignment or a function call which looks up the length of an array and performs an assignment?')
}
ready
Array.map
const arr = new Array(1000).fill(undefined);

const mappedValues = arr.map(() => 'What is faster: an assignment or a function call which looks up the length of an array and performs an assignment?')
ready

Revisions

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