Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript operator double pipes

// Returns the right-hand operand if the left-hand is 0, false, empty string{, null, undefined or NaN
0 || "other" // "other"
false || "other" // "other"
"" || "other" // "other"
null || "other" // "other"
undefined || "other" // "other"
NaN || "other" // "other"

({}) || "other" // {}
[] || "other" // []
 
PREVIOUS NEXT
Tagged: #javascript #operator #double #pipes
ADD COMMENT
Topic
Name
2+1 =