Existential Operator / Null Propagation Operator

Laurentiu Macovei alonecomp at gmail.com
Thu Oct 29 18:22:47 UTC 2015

This would be amazing operator!!

var error = a.b.c.d; //this would fail with error if a, b or c are null or
var current = a && a.b && a.b.c && a.b.c.d; // the current messy way to
handle this
var typeScript = a?.b?.c?.d; // The typescript way of handling the above
mess with no errors

However I propose a more clear one - as not to confuse ? from the a ? b : c
statements with a?.b statements:

var x = a..b..c..d; //this would be ideal to understand that you assume
that if any of a, b, c is null or undefined the result will be null or

Two dots, means if its null or undefined stop processing further and assume
the result of expression is null or undefined. (as d would be null or

Two dots make it more clear, more visible and more space-wise so you
understand what's going on.

What do you think folks?

Best Regards,
Laurenţiu Macovei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151029/afd7d6a9/attachment.html>

More information about the es-discuss mailing list