Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

reduce javascript

let arr = [{
name:"MAERON",
target:1,
},
{
name:"MAERON1",
target:1,
}]

let final = arr.map(x=> Object.keys(x).filter(x=> ['target'].includes(x)).reduce((a,b)=> {
a[b] = x[b]
return a
},{}))
console.log(final)
Source by jsbin.com #
 
PREVIOUS NEXT
Tagged: #reduce #javascript
ADD COMMENT
Topic
Name
9+7 =