Vote count:
0
I have feeling this must be a duplicate, but I've been unable to find anything, probably due to different wording, or just because there really is nothing better.
I am generating kind of huge chunk of JS code, which "ORs" object properties with variables, while identifiers don't necessarily match. It looks like this (values are boolean):
a.borderline = a.borderline || borderline;
a.st1 = a.st1 || st;
a.ref64 = a.ref64 || ref;
...
To make it leaner I tried something like
a.st1 |= st;
but it makes a.st1
integer instead of boolean and I don't want to add another line with double negation to retype it back to boolean.
Using intuition I also tried ||=
, which did not help :)
Is there any better (shorter) way of writing these commands?
asked 39 secs ago
Aucun commentaire:
Enregistrer un commentaire