Test name | Executions per second |
---|---|
Sort and Shift | 78589232.0 Ops/sec |
Loop and Splice | 31055986.0 Ops/sec |
var x = [];
for (let i = 0; i < 1000; ++i) {
x.push({
v: Math.floor(Math.random() * 1000)
});
}
x.sort((a, b) => { return a.v - b.v });
let y = x.shift();
let b = 0;
for (const a in x) {
if (x[a].v < x[b].v) {
b = a;
}
}
let y = x.splice(b, 1);