Test name | Executions per second |
---|---|
if | 46626.6 Ops/sec |
Math.min | 1043.7 Ops/sec |
Cached min | 21867.5 Ops/sec |
arr = Array.from({ length: 10000 }, () => Math.random())
let v = 2;
for (const x of arr) {
if (x < v) v = x;
}
return v;
let v = 2;
for (const x of arr) {
v = Math.min(v, x);
}
return v;
const min = Math.min;
let v = 2;
for (const x of arr) {
v = min(v, x);
}
return v;