需求如下:
let showArr = [{
malltype: '旗舰店',
symbol: 'R标',
region: '华南地区',
industry: '美容护理',
price: '5万-10万'
}, {
malltype: '旗舰店',
symbol: 'R标',
region: '华南地区',
industry: '服饰鞋包',
price: '5万-10万'
}, {
malltype: '旗舰店',
symbol: 'R标',
region: '华南地区',
industry: '游戏话费',
price: '5万-10万'
}] //筛选对象
let reqArr = ['旗舰店', '服饰鞋包'] //筛选条件value,且不确定对应的属性
输出:[{
malltype: '旗舰店',
symbol: 'R标',
region: '华南地区',
industry: '服饰鞋包',
price: '5万-10万'
}]
目前已有的一个思路:
let temp = [];
let cache;
reqArr.forEach(function(item, index) {
showArr.forEach(function(sub) {
cache = Object.values(sub)
cache.forEach(function(part, count) {
if (part == item) {
// console.log(item)
temp = [];
temp.push(sub)
}
})
})
})
console.log(temp);