I'm still getting used to destructuring in ES2015/ES6 and wondered if there's a nice way to clone certain keys of an object using it. It's a little hard to explain in words so I'll let the code do the talking. Here's a simplified version of what I have at the moment:
const objectWithLoadsOfData = {
a: 'a',
b: 'b',
c: 'c',
d: 'd'
};
const objectWithDataSubset = {
a: objectWithLoadsOfData.a,
b: objectWithLoadsOfData.b
}
It works, but it seems like it could be simplified with destructuring somehow. Potentially something like:
const objectWithDataSubset = objectWithLotsOfData {a, b};
Obviously this is invalid, but is there something like this that exists?