Test name | Executions per second |
---|---|
Switch | 761796352.0 Ops/sec |
Map | 1404946.4 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;
default:
return 11;
}
const input = 10;
const mapping = new Map([
[0, true],
[1, true],
[2, true],
[3, true],
[4, true],
[5, true],
[6, true],
[7, true],
[8, true],
[9, true],
[10, true],
]);
const foo = mapping.get(10);