Operators
Logical and assignment (&&=)
Writes the right value only when the current target value is truthy. Otherwise no assignment is performed. The target is evaluated once and the right side is conditional.
Formal Syntax & Structure
javascript syntaxjavascript
target &&= fallbackParameters & Attributes
| Name | Type | Description |
|---|---|---|
| target | assignment target | Current value is tested before a possible write. |
| fallback | expression | Evaluated only when the relevant condition holds. |
Return Value
operand value
Old value if skipped, otherwise the written value.
Working Example
Example Snippetjavascript
let n = true;console.log(n &&= false);