Multiple Object Destructing

Hi and nice meeting you all.

I'd like to share one of my ideas that I got lately, perhaps was already said or recommended by someone but I am not sure yet. If so, than my apologies.

How does this feature work?

Usually when we destruct an object would be as the following -

const { MyProperty } = MyObject

My suggestion would be if you have multiple objects you would be able to destruct from them on the same line, how?

const { MyPropertyObj1, MyPropertyObj2 } = MyObject1 && MyObject2

I am not sure if we should use an && or an ||, perhaps even | is enough but could conflict with typescript than.

I believe this could be a powerful feature.

I hope that each one of you like the idea and please put your input on the improvements for this

Best regards,
Redeemer Pace

Neither && nor ||, because both have already some well-defined meaning.

But as of today, you can already write:

const { MyPropertyObj1, MyPropertyObj2 } = Object.assign({}, MyObject1, MyObject2)

You're right on && ||, they're well defined, perhaps some other universal character.

Well true you can use it the way you mentioned, I tried to simplify it.

Can also be used as
const { MyPropertyObj1, MyPropertyObj2 } = { ...MyObject1, ...MyObject2 }.

But issue than would be same key on both objects, perhaps could be refined better on destructing properties than, unless able to rename the property of a and b.

Thanks for reply!

If both objects have the same key, you always have the same question about which one takes precedence when combining the two objects.

Agreed on that

If I've any better ideas will make new topic, though thanks for everyone sending their feedback and perhaps at the moment it is enough good

Thanks for reply!