Existential Operator / Null Propagation Operator

Sander Deryckere sanderd17 at gmail.com
Tue Jun 2 17:31:41 UTC 2015

2015-06-02 18:57 GMT+02:00 Brendan Eich <brendan at mozilla.org>:

> You might hope for that, but as we both noted, `?[` is not going to fly.
> Don't break the (minified) Web.

Which is why my proposal was about `??`. I believe there's currently no
valid way to use a double question mark in  JS, so even `??[` should be
easy to figure out what it means.

> The prefix idea generalizes:
> ?obj[key]
> obj[?key]
> obj[key1][?key2]
> and if you are not using computed property names, rather literal ones:
> obj.?prop1
> etc.

I found this syntax to conflict with itself. As Andreas Rossberg says, what
does `orders[?client.key].price` mean? Does it mean "check if the client
exists, and if not, return the price of the null order", or does it mean
"check if the order for this client exists, and return null if it doesn't"?
I don't see a way how both meanings can be made possible with this form of
prefix notation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150602/30338d68/attachment.html>

More information about the es-discuss mailing list