鍍金池/ 問答/Linux  HTML/ 關(guān)于依靠a數(shù)組篩選b數(shù)組內(nèi)沒有存在a數(shù)組元素

關(guān)于依靠a數(shù)組篩選b數(shù)組內(nèi)沒有存在a數(shù)組元素

A數(shù)組--tableSelectParams:["id","device_code","value"]
B數(shù)組-- "tag_columns":[{

                    "column_desc": "id",
                    "column_name": "id",
                    "isShow": true
                    },
                    {
                    "column_name": "device_code",
                    "column_desc": "設(shè)備編號(hào)",
                    "isShow": true
                    },
                    {
                    "column_name": "companyid",
                    "column_desc": "公司ID",
                    "isShow": true
                    },
                    {
                    "column_name": "addtime",
                    "column_desc": "添加時(shí)間",
                    "isShow": true
                    },
                    {
                    "column_name": "value",
                    "column_desc": "值",
                    "isShow": true
                    }
                ]

請問如何找出B數(shù)組中 column_name沒有和A數(shù)組元素相同的B數(shù)組對象。
求幫忙看看。

回答
編輯回答
懷中人
// 生成映射表,避免過多的內(nèi)循環(huán)
var map = tableSelectParams.reduce((p, c) => [p[c] = false, p][1])
var result = tag_columns.filter(i => map[i.column_name])
2018年6月9日 13:04
編輯回答
寫榮
let columns = tag_columns.filter(cur => !tableSelectParams.includes(cur.column_name))
2017年7月12日 22:00