Test name | Executions per second |
---|---|
Math.max/min | 4177738.8 Ops/sec |
if | 993319168.0 Ops/sec |
ternary | 1003176192.0 Ops/sec |
this.number = Math.random() * 1000;
return Math.max(250, Math.min(750, this.number));
var number = this.number;
if(number < 250) return 250;
if(number > 750) return 750;
return number;
var number = this.number;
return number < 250 ? 250 : (number > 750 ? 750 : number);