Destructure An Array Parameter
Is it possible to destructure a function parameter? For example, I would want to convert this: Object.entries({}).find(group=> group[0] === 'foo' && group[1] === 'bar');
Notice that to destruct the arrow function parameters you should do ([key, value])
Code:
const obj = {
asdf: 'asdf',
foo: 'bar'
};
const result = Object
.entries(obj)
.find(([key, value]) => key === 'foo' && value === 'bar');
console.log(result);
Post a Comment for "Destructure An Array Parameter"