For example, my array filter on user status works correctly, but I only want the users' name and id with no other fields in the response.
let users = [{
id: 1,
name: 'Zen',
age: 21,
status: true
}, {
id: 2,
name: 'Roy',
age: 29,
status: false
}, {
id: 3,
name: 'Zohn',
age: 41,
status: true
}]
let result = users.filter(({status, age}) => status === true);
console.log('result', result);
Log of result:
[{
id: 1,
name: 'Zen',
age: 21,
status: true
}, {
id: 3,
name: 'Zohn',
age: 41,
status: true
}]
But what I want is:
[{
id: 1,
name: 'Zen',
}, {
id: 3,
name: 'Zohn',
}]