Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Chrome 127
Windows
Desktop
5 months ago
Test name Executions per second
Sort and Shift 11077482.0 Ops/sec
Loop and Splice 10177517.0 Ops/sec
Script Preparation code:
AخA
 
var x = [];
for (let i = 0; i < 1000; ++i) {
    x.push({
        v: Math.floor(Math.random() * 1000)
    });
}
Tests:
  • Sort and Shift

     
    x.sort((a, b) => { return a.v - b.v });
    let y = x.shift();
  • Loop and Splice

     
    let b = 0;
    for (const a in x) {
      if (x[a].v < x[b].v) {
        b = a;
      }
    }
    let y = x.splice(b, 1);