Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Chrome 123
Windows
Desktop
one year ago
Test name Executions per second
splice 3339.7 Ops/sec
filter 1152.7 Ops/sec
Script Preparation code:
AخA
 
var arr = new Array(15000);
arr.fill({ id: 0 });
arr = arr.map((el, idx) => el.id = idx);
var foo = Math.floor(Math.random() * 15000);
Tests:
  • splice

     
    var index = arr.indexOf(foo);
    var newArr = [...arr].splice(index, 1);
  • filter

     
    var index = arr.filter(el => el !== foo)