Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

var arr = [
    {
      "fdId": "1ech3enh02snwcw1q9fd0q2jv026k1hb",
      "actionType": "agree",
      "triggerTime": 48,
    },
    {
      "fdId": "1ecp2el9j35ow2dw34t42dd1klcdea1s",
      "actionType": "forward",
      "triggerTime": 27,
    }
  ]

生成一个新数组,把fdId替换成id
应该怎么转换


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
344 views
Welcome To Ask or Share your Answers For Others

1 Answer

var arr = [
    {
      "fdId": "1ech3enh02snwcw1q9fd0q2jv026k1hb",
      "actionType": "agree",
      "triggerTime": 48,
    },
    {
      "fdId": "1ecp2el9j35ow2dw34t42dd1klcdea1s",
      "actionType": "forward",
      "triggerTime": 27,
    }
];
var newArr = [];

arr.forEach(({ fdId, ...rest }) => newArr.push({ id: fdId, ...rest }));

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...