Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36
Chrome 89
Windows
Desktop
3 years ago
Test name Executions per second
findIndex non-primitive 2634.8 Ops/sec
findIndex primitive 1172.2 Ops/sec
Script Preparation code:
x
 
var arrN = new Array(15000);
for (var i = 0; i < 15000; i++) {
    arrN[i] = { id: i };
}
var randN = Math.floor(Math.random() * 15000);
var arrP = new Array(15000);
for (var i = 0; i < 15000; i++) {
    arrP[i] = i;
}
var randP = Math.floor(Math.random() * 15000);
Tests:
  • findIndex non-primitive

     
    var indexN = arrN.findIndex((num) => num['id'] === randN);
  • findIndex primitive

     
    var indexP = arrP.findIndex((num) => num === randP);