DEV Community

Discussion on: Logical assignment operators in JavaScript

Collapse
 
fkereki profile image
Federico Kereki

Hi! I'm not sure -- isn't x ||= y the same as x = x || y ? This is aligned to how other operators (+=, *=, etc.) do work.

Collapse
 
hemanth profile image
hemanth.hm • Edited

x ||= 1 would mean x || (x = 1)

Collapse
 
cascandaliato profile image
cascandaliato

Aren't the two expressions x = x || y and x || (x = y) equivalent?