> So I've also never come across "|=" being used for this purpose.
IIRC, the JavaScript implementation of "|=" can potentially be used in the way Claudio described it, instead it's based on the truthiness of the left-hand operand rather than it being "unset". But it works in that context because "null" and "undefined" are considered falsey [1]. For example:
> var value = null;
> var other = 2;
> value |= other;
> console.log(value);
2
So it effectively works like "value | other", but also sets "value" to "other" iff "value" is falsey. When the left-hand operand is truthy, it effectively does nothing.
> var value = 3;
> var other = 2;
> value |= other;
> console.log(value);
3
Also worth noting, since "value |= other" translates to "value = value | other", it works as a bitwise OR operator; not as a catch-all for assigning a default value:
> var value = null;
> var other = "test";
> value |= other;
> console.log(value);
0
Instead, you'd have to use the standard OR operator, like this "value = value || other" (since "||=" is invalid syntax):
> var value = null;
> var other = "test";
> value = value || other;
> console.log(value);
test
FWIW, I have very rarely seen "|=" used as an operator in JS, but I've seen "value = value || other" used a decent amount.
---