An array is as follows :
const arr = [ { name: 'Aditya', hobbies: ['Football', 'Basketball'] },
{ name: 'Amitabh', hobbies: [] },
{ name: 'Akhsara', hobbies: ['Basketball'] },
{ name: 'Aia', hobbies: [] }
];
Using filter function as follows:
public getDatas(hobby) {
const data = _.filter(arr, {hobbies : hobby === 'Unclear' : [] ? [hobby]} );
}
I have some how set the Unclear hobbies to empty arrays, when it is Unclear then it is NOT returning me the data with hobbies : [] instead it is returning me the whole of arr.