My data is structured like this:
obj = {
_id: "sjkd9skj",
data: {
dektop: [
{
x: 2,
y: 3,
t: { key: 'aabbcc'}
},
...
],
mobile: [
{
x: 4,
y: 3,
t: { key: 'ffff'}
},
...
],
print: [
{
x: 7,
y: 5,
t: { key: 'ppp'}
},
...
]
}
}
In data, I need to remove all t keys from all array elements for all modes (desktop,mobile,print).
What would be the most efficient way to do this? These mode arrays can get quite large.
I have tried it like this:
obj.data.mobile.forEach((item)=>{
delete item.t;
});
obj.data.desktop.forEach((item)=>{
delete item.t;
});
obj.data.print.forEach((item)=>{
delete item.t;
});
Which does actually not manipulate the obj in this case, so it did not work. Any better suggestions?
ts are removed ...objwas returned from graphql call. Seems like I would have to deebug deeper. or copy said object, which I don't want to do.