A way to prevent properties to be added to an object if they are null or undefined.

Naveen Chawla naveen.chwl at gmail.com
Wed Nov 29 06:54:24 UTC 2017

What is the end goal of this proposal? To reduce the size of a serialized
JSON? I can't see any other use for it. If that's the case, then perhaps a
stringify that skips undefineds and nulls is more appropriate. Otherwise,
what is the purpose / example case where this would be useful?

On Wed, 29 Nov 2017 at 12:01 Rodrigo Carranza <rodrigocarranza at outlook.com>

> ------------------------------
> > I was about to hit send on a post also suggesting a helper function, but after thinking about it a bit more, Rodrigo's suggestion resembles extending the optional chaining proposal> https://github.com/tc39/proposal-optional-chaining <https://github.com/tc39/proposal-optional-chaining>
> > into the object literal notation. I suggest using the same character pair, "?.", as is proposed for optional chaining, instead of just "?".
> > ```js
> > let ret = {
> >     couldBeNull?.,
> >     bar?.: couldBeNull
> > }
> > ```
> >
> > The helper function might be best in the case where an empty string value needs the same treatment as null or undefined.
> That proposal is awesome, but I think the real operator here is the `?`, in combination with the chaining operator `?.` but it could be anything with the same semantics `?:` for objects `?.` for chaining `?=` for assignment `??` binary comparison. Just like in Dart but with extended functionality.
> _______________________________________________
> 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/20171129/a1d12619/attachment.html>

More information about the es-discuss mailing list