Similarly to

```js
const { x = 'a' } = {}; // z === 'a'
const { y = 'a' } = { y: undefined }; // z === 'a'
const { z = 'a' } = { z: null }; // z === null
```
I'd like to propose

```js
const { x =? 'a' } = {}; // z === 'a'
const { y =? 'a' } = { y: undefined }; // z === 'a'
const { z =? 'a' } = { z: null }; // z === 'a'
```
Which would handle also null values in default cases

This is because default destructuring introduced in ES6 doesn't handle null
values, null values in JSON are quite common from APIs, it'd be convenient

It's also inspired by the null-coalescing operator
https://github.com/tc39/proposal-nullish-coalescing
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to