Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2020.
The logical AND assignment (&&=) operator only evaluates the right operand and assigns to the left if the left operand is truthy.
Logical AND assignment short-circuits, meaning that x &&= y is equivalent to x && (x = y), except that the expression x is only evaluated once.
No assignment is performed if the left-hand side is not truthy, due to short-circuiting of the logical AND operator. For example, the following does not throw an error, despite x being const:
Neither would the following trigger the setter:
In fact, if x is not truthy, y is not evaluated at all.
| ECMAScript® 2027 Language Specification # sec-assignment-operators |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 8, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.