I would say, yes, i use it quite often. But you have to keep in mind that
Douglas Crockford: Javascript The Good Parts (p. 40)
The || operator produces the value of its first operand if the first operand is truthy. Otherwise, it produces the
value of the second operand.
So if NEWVAR
contains any falsy (false
,null
,undefined
,NaN
,0
,""
) value, the second opertand is evaluated.
As long as you are aware of this you can always use the ||
operator to get default values
Douglas Crockford: Javascript The Good Parts (p. 51)
The || operator can be used to fill in default values:
var middle = stooge["middle-name"] || "(none)";
var status = flight.status || "unknown";