-1

Suppose i have am array of objects like this:

arr = [{time: 1, value: 2, word: 'fdfd'}, {time: 2, value: 3, word: 'dsadsadsa'}]

How to remove the time and word properties from each object? My output should be this:

arr = [{value: 2}, {value: 3}]
user7334203
  • 6,006
  • 20
  • 46
  • 97

1 Answers1

0

You can try with Array.prototype.map() and Destructuring assignment

let arr = [{time: 1, value: 2, word: 'fdfd'}, {time: 2, value: 3, word: 'dsadsadsa'}];
arr = arr.map(({value}) => ({value}));
console.log(arr);
Mamun
  • 62,450
  • 9
  • 45
  • 52