JS: Logical Assignment Operators (??= ||= &&=)
new in ECMAScript 2021
Logical-nullish assignment operator
Logical-or assignment operator
x ||= val-
Assigns val to x if
Boolean(x)eval tofalse. [see JS: Boolean. true false]let xx = 0; xx ||= 4; console.assert(xx === 4); let yy = 1; yy ||= 4; console.assert(yy === 1);
Logical-and assignment operator
x &&= val-
Assigns val to x if
Boolean(x)eval totrue. [see JS: Boolean. true false]let xx = 3; xx &&= 4; console.assert(xx === 4); let x; x &&= 4; console.assert(x === undefined);