Operators

Logical and assignment (&&=)

Try the free JavaScript compiler

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 &&= fallback

Parameters & Attributes

NameTypeDescription
targetassignment targetCurrent value is tested before a possible write.
fallbackexpressionEvaluated 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);
JavaScript Reference