pick equivalen in es6 1

pick equivalen in es6

{...['whitelisted', 'key'].reduce((mem, key) => ({ ...mem, [key]: obj[key] }), {})}

Here is what the above code is Doing:
1. We’re using the reduce method to iterate over the array [‘whitelisted’, ‘key’]
2. We’re using the reduce method to create a new object with the keys whitelisted and key
3. We’re using the spread operator to spread the new object into the object we’re returning

Similar Posts