Two pipe symbols (OR) in this Javascript line

javascript

Solution

(expr1 || expr2)

"Returns expr1 if it can be converted to true; otherwise, returns expr2."

source

So when `expr1` is (or evaluates to) one of these `0,"",false,null,undefined,NaN`, then `expr2` is returned, otherwise `expr1` is returned

Problem

Possible Duplicate: What does “options = options || {}” mean in Javascript? I have seen this in JS: ``` item = item || {}; ``` I'm guessing it's some variation of a ternary operator but what does is actually do?

Original source

Related problems