Is it somehow possible to destructure an object, set a default value, and assign this default value directly to the object's property?
Consider this code
let foo = {};
let {bar = 1} = foo;
console.log(foo); // {}
console.log(bar); // 1
As you can see, foo still doesn't have a bar property. Is there something like below possible, to assign the prop and default value directly to the object:
let {bar = 1: foo.bar}
This is obvious illegal syntax.
Is there any one liner I can use to get foo to be
{bar: 1}
after the destructuring is done?