Existential Operator / Null Propagation Operator

Kagami Rosylight saschanaz at outlook.com
Fri Oct 14 04:44:24 UTC 2016


>From a technical point of view, using ![ instead of ?.[ may work only if you forbid a line terminator before the !

I tried this on [TS Playground](http://www.typescriptlang.org/play/#src=var%20a%20%3D%20%7B%7D%3B%0D%0A%0D%0Aa!%5B3%5D%3B%0D%0Aa%0D%0A!%5B3%5D%3B) and it interestingly changes behavior when there is a line break before `!`.

```js
var a = {};

a![3]; // works as a[3]
a
![3]; // preserves original behavior
```

>but many languages (e.g. Swift, Kotlin, and I think TypeScript 2.0) use it in the inverse direction: non-null assertion for nullable types.

Right. :/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20161014/af9874ca/attachment.html>


More information about the es-discuss mailing list