I have a function:
const mergedPartOfStateWithCurrentSearchValues = (object, valuesToOmit) => {
const {...valuesToOmit, ...rest } = object;
return rest;
};
The first argument is an object. The second argument is an array of string values to omit from the object. I'm trying to return the rest. So this actually doesn't work like that. I've tried to use lodash as well:
const mergedPartOfStateWithCurrentSearchValues = (object, valuesToOmit) => {
const filteredObject = pickBy(object, function (value, key) {
return !valuesToOmit.includes(key)
})
return filteredObject;
};
And it doesn't work as well. I'm running out of ideas. How can I do what I want to and keeping the generic nature of this function?