如何从JavaScript对象删除和更新对象?

时间:2019-07-19 06:16:28

标签: javascript arrays

var data = [
  { id: 0, ssokid: "a", page_no: 1, color: "rgb(255,0,0)", markertext: "text1" },
  { id: 0, ssokid: "b", page_no: 2, color: "rgb(255,255,0)", markertext: "text2" },
  { id: 0, ssokid: "c", page_no: 3, color: "rgb(255,0,0)", markertext: "text3" }
];

我想从数据中删除所有“ id”和“ ssokid”,并将颜色值更改为红色或黄色,而不是rgb格式。

结果必须是这样;

var data = [
  { page_no: 1, color: "red", markertext: "text1" },
  { page_no: 2, color: "yellow", markertext: "text2" },
  { page_no: 3, color: "red", markertext: "text3" }
];

0 个答案:

没有答案