const b = a.{ id, name, age } - Object Cherry Pick

Hello @DenisTRUFFAUT,

I think this has been proposed by @theScottyJam here.

EDIT: We already use : instead of as for renaming.

There is also an inline, rather verbose way to do this using IIFE, destructuring + construction.

const b = (({ id, name, age }) => { id, name, age })(a);

This would be slightly better if your object names are longer than a and b.

Thank you :grinning:.

1 Like