Echo JS 0.11.0


igl 74 days ago. link 1 point
I hate this. I want the way coffee-script implemented it.
Hogging the ternary syntax while keeping compat is killing this feature.

1) func?.(arg) <- wat?
2) foo?.bar?.baz? <- nope.
ferahl 69 days ago. link 1 point
Syntax looks fine to me, how does coffee script do it then?
xat 80 days ago. link 1 point
Cool proposal in general, although there are still cases where _.get is somehow nicer:

const num = _.get(foo, 'bar.baz', 1337);


const num = typeof foo?.bar?.baz !== 'undefined' ? foo?.bar?.baz : 1337;
bevacqua 80 days ago. link 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.
xat 80 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.