Chrome Extension

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);
We are a bunch of lazy programmers so we developed this chrome extension
search code from your favorite search engine
Install Now
Output
[
{
"id": 23,
"typeId": 214,
"groupId": 10,
"tag": "CM0091"
}
]"

JavaScript ES6 filtering object with multiple params 

Search Index Data (The code snippet can also be found with below search text)

JavaScript ES6 filtering object with multiple params
Was this helpful?
0 Comments
Open Code Manager We are hiring