Favorites

JavaScript &&= Logical AND assignment Operator

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
&&=
JavaScript Assignment OperatorThis operator is supported by all modern browsers.
Updated 28th November 2026

The logical AND assignment operator (&&=) assigns a value to a variable only if the variable is currently truthy.

Description

The logical AND assignment operator x &&= y assigns y to x only if x is truthy. If x is falsy, nothing is assigned and y isn't even evaluated. It's short for x && (x = y), and is useful for updating a value only when it exists.

Because it short-circuits, the right-hand side is only evaluated when the assignment actually happens, so any function call or side effect there is skipped when the variable is falsy. And unlike x = x && y, it doesn't perform an assignment at all when x is falsy, which matters for setters and read-only properties.

Common uses include transforming a value only if it's present, such as trimming an optional string, and clearing a related value when a condition is met. The three logical assignment operators, &&=, ||= and ??=, were added to JavaScript together in 2021.

Properties

Operator
&&=
Category
Assignment
Precedence
2 (1 is lowest, 18 is highest)
Associativity
right-to-left

Syntax

x &&= y

Example

let user = { name: 'sam' };
user.name &&= user.name.toUpperCase();
console.log(user.name);
let missing = '';
missing &&= 'changed';
console.log(JSON.stringify(missing));

Browser Support

The following information will show you the current browser support for the &&= operator. Hover over a browser icon to see the version that first introduced support for this operator.

This operator is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee