please add orEqual operator
Peter van der Zee
ecma at qfox.nl
Mon Aug 10 07:55:06 UTC 2015
On Mon, Aug 10, 2015 at 3:50 AM, <myemailum14 at gmail.com> wrote:
> prop ||= 0;
> better than
> prop = prop || 0;
> and it can be even defined like this.
> prop ||= var1 ||= var2 ||= 0;
> but then i dont know how we can use it ike this
> if (num == 3 ||=4 ||=6)
Sounds like you want two operators; `||=` for the compound assignment
case and `||==` and `||===` for the "compare the RHS to the LHS of the
last `===` or `==` op", or something like that. Defining a single op
for both of these cases is likely to lead to ambiguity.
The `||=` (and `&&=`) case has been discussed a couple of times, look
in the esdiscuss archives.
I'm sure something like `||==` has been discussed too though I don't
recall it myself. I tend to use switches myself for this in case perf
is an issue.
More information about the es-discuss