I have an object with multiple properties like so
const someObject = {
id: 'someid',
name: 'somename',
age: 'somenumber',
someproperty: 'xxx',
anotherproperty: 'yyy',
foo: 'bar',
// ... with many more object properties
}
I have a selector function, with someObject
being the input argument, which returns only a few properties of this object.
const functionName = ({id, age, name, foo}) => ({id, age, name, foo});
Is it possible to return destructed argument directly, without the need of repetetive code?
Destructing with ...rest
(and then returning rest) is probably bad option since I have way more object properties that I do not want to return than properties that I need.