This really is a simple one liner via map
and delete
or map
and ES6 destructuring
as shown in the 2 examples bellow:
var data = [{
"first": "Linda",
"last": "Donson",
"salary": "4000USD"
},
{
"first": "Mark",
"last": "Sullivan",
"salary": "3500USD"
}
]
console.log(data.map(x => delete(x.salary) && x))
Also if you are concerned about mutating the object you can simply use ES6 destructuring
and the short object literal notation
to get this:
Object.values(data).map(({first, last}) => ({first, last}))
solved Pick data from array of objects and return new object