naveen.chwl at gmail.com
Thu Dec 21 14:35:51 UTC 2017
Typically `||` is sufficient. Yes if you want to allow empty strings and/or
0, you would need to add checks for those to the left of the `||`, but I'm
The nullish conditional operator, however ( `?.` and `?[`) , I think is a
bigger addition to the language.
On Thu, 21 Dec 2017 at 18:05 Michael Rosefield <rosyatrandom at gmail.com>
> Yes, but that conflates falsey values; `??` *should* be about recognising
> whether values *exist*, not whether they are *truthy*.
> On Thu, 21 Dec 2017 at 12:20 Naveen Chawla <naveen.chwl at gmail.com> wrote:
>> I prefer `u || 0`
>> On Thu, 21 Dec 2017 at 13:56 Sebastian Cholewa <
>> sebastian.cholewa at interia.eu> wrote:
>>> It’s still longer than `??` but instead of:
>>> `(u !== undefined && u !== null) ? u : 0`
>>> one can use:
>>> `u != null ? u : 0`
>>> es-discuss mailing list
>>> es-discuss at mozilla.org
>> es-discuss mailing list
>> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss