const deleteField = (o, f) => {
if (typeof o !== 'object')
return;
if (Object.hasOwn(o, f))
delete o[f];
for (const k of Object.keys(o)) {
if (typeof o[k] != 'object' || o[k] == null || o[k] == 'undefined')
continue;
if (Object.prototype.toString.call(o[k]) == '[object Array]') {
o[k].forEach(x => {
deleteField(x, f);
});
}
else
deleteField(o[k], f);
}
}
Explanation with an example with be posted soon…