push vs. assign to last index

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
push
let arr = [];
for (let i = 0; i < 100000; i++) {
	arr.push(i);
}
ready
assign last index
let arr = [];
for (let i = 0; i < 100000; i++) {
	arr[arr.length] = i;
}
ready
assign last index (reverse order)
let arr = [];
for (let i = (10000-1); i >= 0; i--) {
	arr[i] = i;
}
ready

Revisions

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