const fake_limit = 1_000;
const fake_array = Array(fake_limit);
{
console.time('unshift-length');
for (let offset = 0; offset <= 1_000_000; ++offset)
{
fake_array.unshift(offset);
fake_array.length = fake_limit;
}
console.timeEnd('unshift-length');
};
{
console.time('push-splice');
for (let offset = 0; offset <= 1_000_000; ++offset)
{
const new_len = fake_array.push(offset);
const removes = new_len - fake_limit;
if (removes > 0)
{
fake_array.splice(0, removes);
}
}
console.timeEnd('push-splice');
};
To embed this project on your website, copy the following code and paste it into your website's HTML: