Test name | Executions per second |
---|---|
findIndex | 8137.9 Ops/sec |
for loop | 38943.2 Ops/sec |
var arr = new Array(15000);
arr.fill({ id: 0 });
arr = arr.map((el, idx) => el.id = idx);
var foo = Math.floor(Math.random() * 15000);
arr.findIndex((itm) => itm.id === foo);
for (let i = 0; i < arr.length; i++) {
if (arr[i].id === foo) break;
}