仅从对象数组中选择特定属性

use*_*222 5 javascript typescript

假设我创建这样的对象:

updates.push({
      id: this.ids[i],
      point: point,
      value: value
    });
Run Code Online (Sandbox Code Playgroud)

后来我想在对象JSON.stringify上使用updates,但是我只需要 point并且value 喜欢:

updates[{point: 1, value: 12}, {point: 2, value: 24}]
Run Code Online (Sandbox Code Playgroud)

最好的 ES6 解决方案是什么?

我查看了一些带有删除的示例,但这不是我真正需要的,因为我不想删除 ids。

amr*_*ngh 7

尝试以下操作:

JSON.stringify(updates.map(({point,value})=>({point,value})));
Run Code Online (Sandbox Code Playgroud)

JSON.stringify(updates.map(({point,value})=>({point,value})));
Run Code Online (Sandbox Code Playgroud)