Le 20 mai 2014 à 05:50, Dmitry Soshnikov <[email protected]> a écrit :
> Hi,
>
> (I remember, I mentioned this couple of years ago, but not sure about whether
> it was considered, etc)
>
> Will the "Existential Operator" for properly accessors be something
> interesting to consider for ES7 spec? Currently CoffeeScript uses it well.
>
> ```js
> var street = user.address?.street;
> ```
>
> The `street` is either the value of the `user.address.street` if the
> `address` property exists (or even if it's an object), or `null` /
> `undefined` otherwise.
>
> This (roughly) to contrast to:
>
> ```js
> var street = user.address && user.address.street;
> ```
>
> (the chain can be longer in many cases).
>
> The same goes with methods:
>
> ```js
> var score = user.getPlan?().value?.score;
> ```
>
> If potentially it could be interesting for ES7, I'll be glad helping with the
> proposal, grammar and algorithm (unless it was considered previously, and
> decided that it's not for ES for some reason).
>
> P.S.: I tried to solve this issue using default values of destructuring
> assignment, but it doesn't help actually.
>
> Dmitry
Question: What is the semantics of the following:
a?.b.c
Is it the same thing as
(a?.b).c
(a && a.b).c
or the same thing as:
a && a.b.c
(For the sake of the argument, just ignore the distinction between "falsy" and
"null/undefined".)
If it is the second option, I fear that the semantics of the so-called
"existential operator" is more complicated than just an "operator".
—Claude
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss