Null-coalescing default values in destructuring

guest271314 guest271314 at
Fri May 10 14:32:36 UTC 2019

The bytes used for code can be reduced. Used redundancy in the original
code to handle both cases at the actual examples at OP.
```JSON.stringify()``` and ```replace()``` could be used. The original
proposal mentions ```JSON```, though includes the case of

const { y =? 'a' } = { y: undefined }; // z === 'a'
which is not valid ```JSON``` but a JavaScript plain object. The brief
example handles ```JSON``` and/or JavaScript plain object input.

There would probably at least that amount of code to implement the
extension to the ```=``` operator in JavaScript.

On Fri, May 10, 2019 at 8:58 AM Oliver Dunk <oliver at> wrote:

> > Given input valid JSON JSON.parse() or JSON.stringify() replacer
> function can be utilized to substitute "undefined" for null.
> guest271314, that’s a lot of code! It feels like if anything, your example
> backs up the proposal.
> > `const { z =? 'a' } = { z: null };`
> I’m not sure I like the proposed syntax. The question mark indicates to me
> that it’s the value on the lhs that’s optional - when in reality, it’s the
> other way around.
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list