当前,我的代码是console.log("body:", body.readResults)
。但是我不希望值t
和r
。如何取消选择它们并得到其余的?
"readResults": [
{
"id": "Channel1.Device1.Coil",
"s": true,
"r": "",
"v": true,
"t": 1553586722927
}
]
答案 0 :(得分:0)
您可以轻松做到:
function cleanMyResult(result) {
const cleanResult = Object.assign({}, result); // this will preserve your original object, but it costs some performance
delete cleanResult.t;
delete cleanResult.r;
return cleanResult;
}
const cleanedResults = body.readResults.map(cleanMyResult);
console.log(cleanedResults);
请同时检查很多已经很好的答案: