Javascript Math Object Methods - negatives to zero

Solution 1:

Just do something like

value = value < 0 ? 0 : value;

or

if (value < 0) value = 0;

or

value = Math.max(0, value);

Solution 2:

I suppose you could use Math.max().

var num = 90;
num = ~~Math.max(0,num); // 90

var num = -90;
num = ~~Math.max(0,num); // 0