Decrease a value until zero and stop there

Let's assume that you want to decrease a value until it reaches zero and stop there.

Example:

javascript
if(value > 0)
    value --;
else
    value = 0;

An alternative to the previous code:

javascript
value = value - 1 < 0 ? 0 : value - 1; 

Another one:

javascript
value = Math.max(0, value - 1);

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.