Test name | Executions per second |
---|---|
findIndex non-primitive | 2634.8 Ops/sec |
findIndex primitive | 1172.2 Ops/sec |
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);
var indexN = arrN.findIndex((num) => num['id'] === randN);
var indexP = arrP.findIndex((num) => num === randP);