On 4/13/11, Kyle Simpson <[email protected]> wrote:
>>>
>>> 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.
>
That is true. So you want `a` undefined iff `b` is falsy. I'm not sure
I'd need that but perhaps in that case:
var a = b && c || a;

Reads easier grouped (to me).
var a = (b && c) || a;
-- 
Garrett
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to