Just learned JavaScript has logical OR assignment and logical AND assignment


Just learned JavaScript has logical OR assignment and logical AND assignment! 🔥

Logical AND assignment:
x &&= "x is truthy" // assigns if the left side is truthy

Logical OR assignment:
x ||= "x is falsy" // assigns if the left side is falsy

#javascript

More on MDN:

Logical AND assignment: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND_assignment

Logical OR assignment: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR_assignment

View original on X