javascript

JavaScript ES6 filtering object with multiple params

let equipmentsReturn = [
                { id: 23, typeId : 214 , groupId :10, tag:"CM0091"}, 
                { id: 11, typeId : 314 , groupId :10, tag:"CM009"}, 
                { id: 435, typeId : 412 , groupId :10, tag:"CM009"},
                { id: 23231, typeId : 2142312 , groupId :10, tag:"CM009"}, 
                { id: 1231231, typeId : 31444 , groupId :10, tag:"CM009"}, 
                { id: 48882, typeId : 412331 , groupId :10, tag:"CM009"},
                { id: 20, typeId : 12356734 , groupId :10, tag:"CM009"},
                { id: 31, typeId : 8888888 , groupId :10, tag:"CM009"},
                { id: 31236566, typeId : 100 , groupId :10, tag:"CM009"},
                { id: 31236566, typeId : 200 , groupId :10, tag:"CM009"}

            ];
            let arraytype = [214];
            let arraygroupId = [ 86, 77];
            let arraytag = ["CM119","CM977"];

            const filtered = equipmentsReturn.filter(({ typeId ,groupId , tag}) =>
            arraytype.includes(typeId) || arraygroupId.includes(groupId) || arraytag.includes(tag) );
            
           console.log(filtered);
Output
[
{
"id": 23,
"typeId": 214,
"groupId": 10,
"tag": "CM0091"
}
]"

JavaScript ES6 filtering object with multiple params 

Was this helpful?