It gives a default value in the case that a parameter or return was missing (undefined
). It's idiomatic and confusing to newcomers, but it is a better idea than just letting things go undefined
. In the case of || 0
, maybe you'll be doing some math later, and if assigned without that default, you'll start seeing NaN
everywhere.