Proposing a conditional assignment (or equals) operator

Isiah Meadows isiahmeadows at gmail.com
Tue May 10 15:18:19 UTC 2016


Thought I'd mention this has been discussed before:

- https://esdiscuss.org/topic/existential-operator-null-propagation-operator
- https://esdiscuss.org/topic/the-existential-operator
-
https://esdiscuss.org/topic/optional-chaining-aka-existential-operator-null-propagation
- https://esdiscuss.org/topic/proposal-for-a-null-coalescing-operator
- https://esdiscuss.org/topic/operator-was-es6-doesn-t-need-opt-in

Currently, here's what I've seen emerge out of these discussions as the
most likely, each of them chainable:

1. `x ?? y` for `x != null ? x : y`
2. `x??y` or `x?.y` for `x != null ? x.y : undefined`

In #2, the operator works similarly for computed access, function calls,
etc., like in `f?.(x)` equivalent to `f != null ? f(x) : undefined`

On Tue, May 10, 2016, 08:50 Bruno Jouhier <bjouhier at gmail.com> wrote:

> `??=` is cleaner and avoids problems when the default is falsy but not
> undefined. But then we also need `??`.
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160510/7d5435e1/attachment.html>


More information about the es-discuss mailing list