The other (more awkward/obscure looking) way to do this is:
var a;
b && a = c;
a = b && c;
That is not the same thing. Your code assigns `b` to `a` if `b` is falsy .
The other code either leaves `a` as undefined (strictly doesn't assign) if
the test fails, or assigns it the value of `c` (no matter what the type of
`c` is) if the test succeeds.
Your suggestion to change the ternary operator is interesting but
creates incompatibility. It is not feasible.
I'm curious what "incompatibility" you mean? If we're talking about
backwards compatibility... of course. But a lot of the ES-Harmony (and
later) stuff is of that same persuasion. I'm simply saying if we're talking
about adding sugar to these operators for future versions of ES, this is one
pattern I end up typing a LOT and it would be helpful.
Or is there some ambiguity of top-down parsing that I'm missing?
--Kyle
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss