Echo JS 0.11.0

<~>
bevacqua 2701 days ago. link parent 3 points
Generally you would do `foo?.bar?.baz || 1337`, unless `baz` was expected to sometimes have a significant falsy value.

I've talked about an idea to introduce `??` (from C#, null coalescing operator), which provides default values for undefined case only (not all of falsy), with which `foo?.bar?.baz ?? 1337` would be equivalent to the top line in your code.

Replies

xat 2700 days ago. link 1 point
Yeah, I intentionally did the example with a number, because there you have the problem of 0 being falsy.
The `??`-solution would be nice IMHO.