What does the || operator do?

The || operator in JavaScript returns the value on the left if that value does not evaluate to false, otherwise it returns the value on the right.

From Mozilla’s Core JavaScript 1.5 Reference:

expr1 || expr2
Returns expr1 if it can be converted to true; otherwise, returns expr2. Thus, when used with Boolean values, || returns true if either operand is true; if both are false, returns false.

So, in this case, if Attacklab.wmd_env.buttons doesn’t have a value, it sets the value to _4.

Leave a Comment