closure-compiler
closure-compiler copied to clipboard
Logical Assignment Operators [Feature Request]
Would you please add logical assignment operators as the proposal is in stage 4:
a ||= b;
a &&= b;
a ??= b;
https://github.com/tc39/proposal-logical-assignment
Thanks for the report, this does look like a very useful ES2021 feature.
(Full list is at https://github.com/tc39/proposals/blob/master/finished-proposals.md)
yes, i currently use this syntax for singletons:
class Singleton {
static instance() {
return this.instance ?? (this.instance = new this());
}
}
which can be replaced by:
return this.instance ??= new this();