Test name | Executions per second |
---|---|
Array to Map and find | 110867.3 Ops/sec |
Array.find | 7229953.5 Ops/sec |
data = [Array(100)].map((_, id) => ({ id, data: Math.random() }))
const res = new Map(data.map(v => [v.id, v])).get(50)
const res = data.find(({ id }) => id === 50)