-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}]
RamAlx
  • 6,976
  • 23
  • 58
  • 106

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
  • 66,969
  • 9
  • 47
  • 59