could you help me with code which delete all objects in array?
in my example i have array which contains Objects.
Every object contains keys and i want to look at every key and check if it is Object.
If it is Object i want to delete that key( In my example i just rewrite its value to empty string)
if(typeof result2.length == 'number'){
for(var u in result2){
Object.keys(result2[u])
.filter(k => typeof result2[u][k] === 'object')
.map(k => delete result2[u][k])
}
}else{
Object.keys(result2)
.filter(k => typeof result2[k] === 'object')
.map(k => delete result2[k])
}
My code which works if result2 containts more Objects.
If it contain only 1 object it does not work.
If input contain only 1 object its change from array to object.