2017-09-26 20 views
-2

配列を持っています。別の配列のキーに基づいて反復してフィルタリングしたい配列があります。最初の配列を反復処理し、 2番目の配列。私は配列のフィルタを使用する必要がありますが、私はどのように2番目の配列をフィルタとして渡すことができないと知っている。別の配列の値を持つ配列をフィルタリングする

var arr =[ 
 
    [ 
 
    { 
 
     "name": "SEASONAL_LYQ1", 
 
     "code": "SEASONAL_LYQ1", 
 
     "parent": "SEASONAL_POP", 
 
     "value": 0, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "SEASONAL_LYQ2", 
 
     "code": "SEASONAL_LYQ2", 
 
     "parent": "SEASONAL_POP", 
 
     "value": 19, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "SEASONAL_LYQ3", 
 
     "code": "SEASONAL_LYQ3", 
 
     "parent": "SEASONAL_POP", 
 
     "value": 40, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "SEASONAL_LYQ4", 
 
     "code": "SEASONAL_LYQ4", 
 
     "parent": "SEASONAL_POP", 
 
     "value": 22, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "SEASONAL_CYQ1", 
 
     "code": "SEASONAL_CYQ1", 
 
     "parent": "SEASONAL_POP", 
 
     "value": 0, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "SEASONAL_CYQ2", 
 
     "code": "SEASONAL_CYQ2", 
 
     "parent": "SEASONAL_POP", 
 
     "value": 20, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "SEASONAL_CYQ3", 
 
     "code": "SEASONAL_CYQ3", 
 
     "parent": "SEASONAL_POP", 
 
     "value": 40, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "SEASONAL_CYQ4", 
 
     "code": "SEASONAL_CYQ4", 
 
     "parent": "SEASONAL_POP", 
 
     "value": 24, 
 
     "children": [] 
 
    } 
 
    ], 
 
    [ 
 
    { 
 
     "name": "Total Educated", 
 
     "code": "Q035001", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "9891", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Grade  Less than 9", 
 
     "code": "Q035003", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "514", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Grade 9 to 12", 
 
     "code": "Q035007", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "444", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "High School", 
 
     "code": "Q035011", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "1269", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Some College", 
 
     "code": "Q035012", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "2001", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "College Degree -  Associate's", 
 
     "code": "Q035014", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "400", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "College Degree -  Bachelor's", 
 
     "code": "Q035015", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "3018", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "College Degree -  Master's", 
 
     "code": "Q035016", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "1706", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "College - Professional", 
 
     "code": "Q035017", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "315", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "College Degree - Doctorate", 
 
     "code": "Q035018", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "224", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Enrollments (Total Population)", 
 
     "code": "EDU_Enrollments", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "children": [ 
 
     { 
 
      "name": "Nursery school/Preschool", 
 
      "code": "Q036003", 
 
      "parent": "EDU_Enrollments", 
 
      "value": "330", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "Kindergarten/Elementary school", 
 
      "code": "Q036006", 
 
      "parent": "EDU_Enrollments", 
 
      "value": "1158", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "High School", 
 
      "code": "Q036015", 
 
      "parent": "EDU_Enrollments", 
 
      "value": "636", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "College/Graduate /Professional school", 
 
      "code": "Q036018", 
 
      "parent": "EDU_Enrollments", 
 
      "value": "1715", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "Not Enrolled", 
 
      "code": "Q036024", 
 
      "parent": "EDU_Enrollments", 
 
      "value": "10324", 
 
      "children": [] 
 
     } 
 
     ] 
 
    }, 
 
    { 
 
     "name": "Percents", 
 
     "code": "PCT_EDU_ATTAINMENT", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "children": [ 
 
     { 
 
      "name": "% Grade  Less than 9", 
 
      "code": "XQ035003", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "5.197", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "% Grade 9 to 12", 
 
      "code": "XQ035007", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "4.4937", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "% High school", 
 
      "code": "XQ035011", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "12.8274", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "% Some college", 
 
      "code": "XQ035012", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "20.2347", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "% College - Associate", 
 
      "code": "XQ035014", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "4.0479", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "% College - Bachelors", 
 
      "code": "XQ035015", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "30.509", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "% College - Masters", 
 
      "code": "XQ035016", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "17.2467", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "% College - Professional", 
 
      "code": "XQ035017", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "3.1824", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "% College - Doctorate", 
 
      "code": "XQ035018", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "2.2612", 
 
      "children": [] 
 
     } 
 
     ] 
 
    } 
 
    ], 
 
    [ 
 
    { 
 
     "name": "1 Person HHs", 
 
     "code": "Q014010", 
 
     "parent": "HH_by_size", 
 
     "value": "2395", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "2 Person HHs", 
 
     "code": "Q014011", 
 
     "parent": "HH_by_size", 
 
     "value": "2140", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "3 Person HHs", 
 
     "code": "Q014012", 
 
     "parent": "HH_by_size", 
 
     "value": "878", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "4 Person HHs", 
 
     "code": "Q014013", 
 
     "parent": "HH_by_size", 
 
     "value": "701", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "5 Person HHs", 
 
     "code": "Q014014", 
 
     "parent": "HH_by_size", 
 
     "value": "247", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "6 Person HHs", 
 
     "code": "Q014015", 
 
     "parent": "HH_by_size", 
 
     "value": "68", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "7+ Person HHs", 
 
     "code": "Q014016", 
 
     "parent": "HH_by_size", 
 
     "value": "54", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Persons Per HH", 
 
     "code": "Q017001", 
 
     "parent": "HH_by_size", 
 
     "value": "2", 
 
     "children": [] 
 
    } 
 
    ], 
 
    [ 
 
    { 
 
     "name": "Occ Managerial Executive", 
 
     "code": "Q050004", 
 
     "parent": "EMP_16P_WHITE_COL", 
 
     "value": "1748", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Prof Specialty", 
 
     "code": "Q050010", 
 
     "parent": "EMP_16P_WHITE_COL", 
 
     "value": "2372", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Healthcare Support", 
 
     "code": "Q050024", 
 
     "parent": "EMP_16P_WHITE_COL", 
 
     "value": "91", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Sales", 
 
     "code": "Q050032", 
 
     "parent": "EMP_16P_WHITE_COL", 
 
     "value": "1323", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Office Admin", 
 
     "code": "Q050033", 
 
     "parent": "EMP_16P_WHITE_COL", 
 
     "value": "623", 
 
     "children": [] 
 
    } 
 
    ], 
 
    [ 
 
    { 
 
     "name": "Occ Protective", 
 
     "code": "Q050025", 
 
     "parent": "EMP_16P_BLUE_COL", 
 
     "value": 75, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Food Preparation Serving", 
 
     "code": "Q050028", 
 
     "parent": "EMP_16P_BLUE_COL", 
 
     "value": 394, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Bldg Maintenance & Cleaning", 
 
     "code": "Q050029", 
 
     "parent": "EMP_16P_BLUE_COL", 
 
     "value": 183, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Personal Care", 
 
     "code": "Q050030", 
 
     "parent": "EMP_16P_BLUE_COL", 
 
     "value": 421, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Farming, Fishing & Forestry", 
 
     "code": "Q050034", 
 
     "parent": "EMP_16P_BLUE_COL", 
 
     "value": 0, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Construction", 
 
     "code": "Q050035", 
 
     "parent": "EMP_16P_BLUE_COL", 
 
     "value": 330, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Production Transportation", 
 
     "code": "Q050041", 
 
     "parent": "EMP_16P_BLUE_COL", 
 
     "value": 404, 
 
     "children": [] 
 
    } 
 
    ], 
 
    [ 
 
    { 
 
     "name": "No Vehicle", 
 
     "code": "Q029003", 
 
     "parent": "VEHICLES_PER_HH", 
 
     "value": "531", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "1 Vehicle", 
 
     "code": "Q029004", 
 
     "parent": "VEHICLES_PER_HH", 
 
     "value": "2808", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "2 Vehicle", 
 
     "code": "Q029005", 
 
     "parent": "VEHICLES_PER_HH", 
 
     "value": "2404", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "3 Vehicle", 
 
     "code": "Q029006", 
 
     "parent": "VEHICLES_PER_HH", 
 
     "value": "555", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "4 Vehicle", 
 
     "code": "Q029007", 
 
     "parent": "VEHICLES_PER_HH", 
 
     "value": "131", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "5 Vehicle", 
 
     "code": "Q029008", 
 
     "parent": "VEHICLES_PER_HH", 
 
     "value": "53", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Aggregate Number of Vehicle", 
 
     "code": "Q029009", 
 
     "parent": "VEHICLES_PER_HH", 
 
     "value": "10078", 
 
     "children": [] 
 
    } 
 
    ] 
 
]; 
 

 
var el = ["Q029009","Q017001","Q035001"]; 
 

 
arr = arr.filter(e => e !== el); 
 
console.log(arr)

Y。

+0

'arr'は、*配列の配列*であり、そして' el'は、文字列の配列です。 'e!== el'を実行することによって、オブジェクトの配列を文字列の配列と比較しています。これは動作しないだけでなく、あなたがしたいことでもありません。 'el'に内部配列のオブジェクトの' code'プロパティが含まれていない内部配列をフィルタリングする必要があります。または* include * - あなたの質問とコードは2つの異なることをしているようです。 – Santi

+0

あなたのスニペットがより簡潔であれば役に立ちます。第二に、なぜ配列内にオブジェクトの配列を作成していますか?私がそれに対して助言する必要がなければ、そのデータ構造は理想的ではありません。 – zfrisch

+0

現在の[フィルタ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)機能は、複雑なデータスキーマには対応していません。 –

答えて

0

あなたは、配列の配列なので、.map()外側の配列を持っており、それぞれの内側の配列のために、現在のオブジェクトの.codeel配列に含まれていません確認します.filter()を返します。

var el = ["Q029009","Q017001","Q035001"]; 
arr = arr.map(a => a.filter(o => !el.includes(o.code))); 

デモ:

var arr =[ 
 
    [ 
 
    { 
 
     "name": "SEASONAL_LYQ1", 
 
     "code": "SEASONAL_LYQ1", 
 
     "parent": "SEASONAL_POP", 
 
     "value": 0, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "SEASONAL_LYQ2", 
 
     "code": "SEASONAL_LYQ2", 
 
     "parent": "SEASONAL_POP", 
 
     "value": 19, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "SEASONAL_LYQ3", 
 
     "code": "SEASONAL_LYQ3", 
 
     "parent": "SEASONAL_POP", 
 
     "value": 40, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "SEASONAL_LYQ4", 
 
     "code": "SEASONAL_LYQ4", 
 
     "parent": "SEASONAL_POP", 
 
     "value": 22, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "SEASONAL_CYQ1", 
 
     "code": "SEASONAL_CYQ1", 
 
     "parent": "SEASONAL_POP", 
 
     "value": 0, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "SEASONAL_CYQ2", 
 
     "code": "SEASONAL_CYQ2", 
 
     "parent": "SEASONAL_POP", 
 
     "value": 20, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "SEASONAL_CYQ3", 
 
     "code": "SEASONAL_CYQ3", 
 
     "parent": "SEASONAL_POP", 
 
     "value": 40, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "SEASONAL_CYQ4", 
 
     "code": "SEASONAL_CYQ4", 
 
     "parent": "SEASONAL_POP", 
 
     "value": 24, 
 
     "children": [] 
 
    } 
 
    ], 
 
    [ 
 
    { 
 
     "name": "Total Educated", 
 
     "code": "Q035001", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "9891", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Grade  Less than 9", 
 
     "code": "Q035003", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "514", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Grade 9 to 12", 
 
     "code": "Q035007", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "444", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "High School", 
 
     "code": "Q035011", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "1269", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Some College", 
 
     "code": "Q035012", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "2001", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "College Degree -  Associate's", 
 
     "code": "Q035014", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "400", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "College Degree -  Bachelor's", 
 
     "code": "Q035015", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "3018", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "College Degree -  Master's", 
 
     "code": "Q035016", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "1706", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "College - Professional", 
 
     "code": "Q035017", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "315", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "College Degree - Doctorate", 
 
     "code": "Q035018", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "value": "224", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Enrollments (Total Population)", 
 
     "code": "EDU_Enrollments", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "children": [ 
 
     { 
 
      "name": "Nursery school/Preschool", 
 
      "code": "Q036003", 
 
      "parent": "EDU_Enrollments", 
 
      "value": "330", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "Kindergarten/Elementary school", 
 
      "code": "Q036006", 
 
      "parent": "EDU_Enrollments", 
 
      "value": "1158", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "High School", 
 
      "code": "Q036015", 
 
      "parent": "EDU_Enrollments", 
 
      "value": "636", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "College/Graduate /Professional school", 
 
      "code": "Q036018", 
 
      "parent": "EDU_Enrollments", 
 
      "value": "1715", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "Not Enrolled", 
 
      "code": "Q036024", 
 
      "parent": "EDU_Enrollments", 
 
      "value": "10324", 
 
      "children": [] 
 
     } 
 
     ] 
 
    }, 
 
    { 
 
     "name": "Percents", 
 
     "code": "PCT_EDU_ATTAINMENT", 
 
     "parent": "EDU_ATTAINMENT", 
 
     "children": [ 
 
     { 
 
      "name": "% Grade  Less than 9", 
 
      "code": "XQ035003", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "5.197", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "% Grade 9 to 12", 
 
      "code": "XQ035007", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "4.4937", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "% High school", 
 
      "code": "XQ035011", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "12.8274", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "% Some college", 
 
      "code": "XQ035012", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "20.2347", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "% College - Associate", 
 
      "code": "XQ035014", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "4.0479", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "% College - Bachelors", 
 
      "code": "XQ035015", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "30.509", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "% College - Masters", 
 
      "code": "XQ035016", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "17.2467", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "% College - Professional", 
 
      "code": "XQ035017", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "3.1824", 
 
      "children": [] 
 
     }, 
 
     { 
 
      "name": "% College - Doctorate", 
 
      "code": "XQ035018", 
 
      "parent": "PCT_EDU_ATTAINMENT", 
 
      "value": "2.2612", 
 
      "children": [] 
 
     } 
 
     ] 
 
    } 
 
    ], 
 
    [ 
 
    { 
 
     "name": "1 Person HHs", 
 
     "code": "Q014010", 
 
     "parent": "HH_by_size", 
 
     "value": "2395", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "2 Person HHs", 
 
     "code": "Q014011", 
 
     "parent": "HH_by_size", 
 
     "value": "2140", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "3 Person HHs", 
 
     "code": "Q014012", 
 
     "parent": "HH_by_size", 
 
     "value": "878", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "4 Person HHs", 
 
     "code": "Q014013", 
 
     "parent": "HH_by_size", 
 
     "value": "701", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "5 Person HHs", 
 
     "code": "Q014014", 
 
     "parent": "HH_by_size", 
 
     "value": "247", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "6 Person HHs", 
 
     "code": "Q014015", 
 
     "parent": "HH_by_size", 
 
     "value": "68", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "7+ Person HHs", 
 
     "code": "Q014016", 
 
     "parent": "HH_by_size", 
 
     "value": "54", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Persons Per HH", 
 
     "code": "Q017001", 
 
     "parent": "HH_by_size", 
 
     "value": "2", 
 
     "children": [] 
 
    } 
 
    ], 
 
    [ 
 
    { 
 
     "name": "Occ Managerial Executive", 
 
     "code": "Q050004", 
 
     "parent": "EMP_16P_WHITE_COL", 
 
     "value": "1748", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Prof Specialty", 
 
     "code": "Q050010", 
 
     "parent": "EMP_16P_WHITE_COL", 
 
     "value": "2372", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Healthcare Support", 
 
     "code": "Q050024", 
 
     "parent": "EMP_16P_WHITE_COL", 
 
     "value": "91", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Sales", 
 
     "code": "Q050032", 
 
     "parent": "EMP_16P_WHITE_COL", 
 
     "value": "1323", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Office Admin", 
 
     "code": "Q050033", 
 
     "parent": "EMP_16P_WHITE_COL", 
 
     "value": "623", 
 
     "children": [] 
 
    } 
 
    ], 
 
    [ 
 
    { 
 
     "name": "Occ Protective", 
 
     "code": "Q050025", 
 
     "parent": "EMP_16P_BLUE_COL", 
 
     "value": 75, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Food Preparation Serving", 
 
     "code": "Q050028", 
 
     "parent": "EMP_16P_BLUE_COL", 
 
     "value": 394, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Bldg Maintenance & Cleaning", 
 
     "code": "Q050029", 
 
     "parent": "EMP_16P_BLUE_COL", 
 
     "value": 183, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Personal Care", 
 
     "code": "Q050030", 
 
     "parent": "EMP_16P_BLUE_COL", 
 
     "value": 421, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Farming, Fishing & Forestry", 
 
     "code": "Q050034", 
 
     "parent": "EMP_16P_BLUE_COL", 
 
     "value": 0, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Construction", 
 
     "code": "Q050035", 
 
     "parent": "EMP_16P_BLUE_COL", 
 
     "value": 330, 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Occ Production Transportation", 
 
     "code": "Q050041", 
 
     "parent": "EMP_16P_BLUE_COL", 
 
     "value": 404, 
 
     "children": [] 
 
    } 
 
    ], 
 
    [ 
 
    { 
 
     "name": "No Vehicle", 
 
     "code": "Q029003", 
 
     "parent": "VEHICLES_PER_HH", 
 
     "value": "531", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "1 Vehicle", 
 
     "code": "Q029004", 
 
     "parent": "VEHICLES_PER_HH", 
 
     "value": "2808", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "2 Vehicle", 
 
     "code": "Q029005", 
 
     "parent": "VEHICLES_PER_HH", 
 
     "value": "2404", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "3 Vehicle", 
 
     "code": "Q029006", 
 
     "parent": "VEHICLES_PER_HH", 
 
     "value": "555", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "4 Vehicle", 
 
     "code": "Q029007", 
 
     "parent": "VEHICLES_PER_HH", 
 
     "value": "131", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "5 Vehicle", 
 
     "code": "Q029008", 
 
     "parent": "VEHICLES_PER_HH", 
 
     "value": "53", 
 
     "children": [] 
 
    }, 
 
    { 
 
     "name": "Aggregate Number of Vehicle", 
 
     "code": "Q029009", 
 
     "parent": "VEHICLES_PER_HH", 
 
     "value": "10078", 
 
     "children": [] 
 
    } 
 
    ] 
 
]; 
 

 
var el = ["Q029009","Q017001","Q035001"]; 
 

 
verify("Found codes before removal:", arr, el); // should be `true` 
 

 
arr = arr.map(a => a.filter(o => !el.includes(o.code))); 
 

 
verify("Found codes after removal:", arr, el); // should be `false` 
 

 
console.log(arr) 
 

 
function verify(msg, arr, el) { 
 
    console.log(msg, arr.some(a => a.some(o => el.includes(o.code)))); 
 
}

関連する問題