Optional Chaining (aka Existential Operator, Null Propagation)

Claude Pache claude.pache at gmail.com
Thu Aug 25 15:41:54 UTC 2016


> Le 25 août 2016 à 17:17, Claude Pache <claude.pache at gmail.com> a écrit :
> 
> 
>> Le 25 août 2016 à 16:05, Alexander Mekhonoshin <invntrm at yandex-team.ru <mailto:invntrm at yandex-team.ru>> a écrit :
>> 
>> 
>> 2. unary ?.
>> 
>> window?.navigator?.toString()
>> 
>> browser: "[object Navigator]"
>> node: ReferenceError: window is not defined
>> 
>> here i suggest syntax for exception-slient accesing globals:
>> 
>> ?.a === hostGlobalObject?.a
>> ?.a?.b === hostGlobalObject?.a?.b
> 
> For accessing the global object, I think that the current System.global proposal is a better call, because it adds no syntax. See:
> 
> https://github.com/tc39/proposal-global <https://github.com/tc39/proposal-global>
> 
> `System.global?.navigator.toString()` is somewhat lengthy, but it is nevertheless simple and clear.
> 

Correction: `System.global.navigator?.toString()`


> —Claude


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160825/9d5cd9e8/attachment.html>


More information about the es-discuss mailing list