These are all equivalent:
this.b = b || 0;
if (b) { this.b=b } else { this.b=0 }
this.b = b ? b : 0;
this.b = 0; if (b) this.b=b;
Obviously the first one is less typing.
The reason the first one works is described fairly well on the MDN:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators
In short:
The && and || operators have a special feature whereby the values are evaluated for truthyness but the value is returned rather than just true or false.
In your case, expr1 || expr2, will return expr1 if it evaluates to true, otherwise expr2 will be returned.