Test name | Executions per second |
---|---|
Switch | 957295744.0 Ops/sec |
Map | 1881327.2 Ops/sec |
const input = 10;
switch(input) {
case 1:
return true;
case 2:
return true;
case 3:
return true;
case 4:
return true;
case 5:
return true;
case 6:
return true;
case 7:
return true;
case 8:
return true;
case 9:
return true;
case 10:
return true;
}
const input = 10;
const LUT = new Map([
[0, true],
[1, true],
[2, true],
[3, true],
[4, true],
[5, true],
[6, true],
[7, true],
[8, true],
[9, true],
[10, true],
]);
LUT.get(input);