Optional Chaining (aka Existential Operator, Null Propagation)
Claude Pache
claude.pache at gmail.com
Fri Feb 5 10:38:30 UTC 2016
> Le 4 févr. 2016 à 21:03, Kevin Smith <zenparsing at gmail.com> a écrit :
>
> (...) The syntax still seems problematic, though, from an aesthetic point of view.
>
> The `obj ?. prop` form looks natural and aligns well with how this feature appears in other languages. The other forms are less natural:
>
> obj?.[expr]
> func?.(...args)
> new C?.(...args)
>
> I'm not particularly convinced by any of the other syntactic variants we've seen.
Yeah, I fear that we couldn’t find a "good" syntax for those, given that `obj?[expr]` and `func?(...args)` are most probably excluded :-(
```js
o.x?[y]+z // should be parsed as: (o.x?[y]) + z
o.x?[y]+z:t // should be parsed as: o.x ? ([y] + z) : t
```
—Claude
More information about the es-discuss
mailing list