Basic Idea
I propose to use the last property of the passed object for the name of returned object.
The example code below shows intended syntax.
Example Code
const users = [{
name:'foo',
age:25,
company:{
name:'companyName'
}
},
{
name:'bar',
age:30,
company:{
name:'companyName2'
}
}];
const companies = users.map(user=>{
return { company: user.company, age:user.age }
})
Example Usage
const users = [{
name:'foo',
age:25,
company:{
name:'companyName'
}
},
{
name:'bar',
age:30,
company:{
name:'companyName2'
}
}];
const companies = users.map(user=>{
return { user.company, user.age }
})