Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

filter array inside array

//you can do a .map to iterate over the first level array
// and return an object that have all the other things in the array with spred operator
// and add a new property that will be the second level array filtered
arrayTier1.map((item) => {
        return ({...item, arrayTier2: item.arrayTier2.filter(subitem => subitem.value == 2)});
 
PREVIOUS NEXT
Tagged: #filter #array #array
ADD COMMENT
Topic
Name
2+6 =