I have the following object
params: {
filter: {
status: '',
color: 'red'
}
}
And I need to remove empty/null values from the params object. How can I do that ?
I have the following object
params: {
filter: {
status: '',
color: 'red'
}
}
And I need to remove empty/null values from the params object. How can I do that ?
Use Object.keys to iterate through the keys. Use the delete
operator when encountering an empty/null value. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete
Make sure to handle cases where an object is nested indeterminately deep.