Operators
Logical or (||)
Returns the left operand when it is truthy; otherwise evaluates and returns the right. Legitimate zero or empty string may be replaced by a fallback.
Formal Syntax & Structure
javascript syntaxjavascript
left || rightParameters & Attributes
| Name | Type | Description |
|---|---|---|
| left | expression | Left operand. |
| right | expression | Right operand; short-circuiting may skip evaluation where applicable. |
Return Value
operand value
Result of the operation.
Working Example
Example Snippetjavascript
console.log("" || "default");