Skip to content

JavaScript – Logical assignment operators

Last updated on January 30, 2021

Logical assignment operators are new compound assignment operators that combine the logical operations &&, ||, or ?? with assignment

x &&= y;
// Roughly equivalent to x && (x = y)
x ||= y;
// Roughly equivalent to x || (x = y)
x ??= y;
// Roughly equivalent to x ?? (x = y)

Note that, unlike mathematical and bitwise compound assignment operators, logical assignment operators only conditionally perform the assignment.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments