I have a complex react state that is structured like this:
{
a: [
{
a: ['b','',]
}
],
b: {
a: ['b',''],
b: {c:'e',f:''}
},
c: 'd',
e: '',
f: ['g',''],
date: new Date()
}
As you can see, could be in the object a lot of empty strings. Before I submit it to the backend, I would like to iterate over the state object and remove all empty values. So I first need to deep clone the state not to mess with my applications state which can be done by:
clone = JSON.parse(JSON.stringify(state))
but how do I iterate over the clone
and remove all empty strings?