需求如下:letshowArr=[{malltype:'旗艦店',symbol:'R標',region:'華南地區',industry:'美容護理',price:'5萬-10萬'},{malltype:'旗艦店',symbol:'R標',region:'華南地區',industry:'服飾鞋包',price:'5萬-10萬'},{malltype:'旗艦店',symbol:'R標',region:'華南地區',industry:'游戲話費',price:'5萬-10萬'}]//篩選對象letreqArr=['旗艦店','服飾鞋包']//篩選條件value,且不確定對應的屬性輸出:[{malltype:'旗艦店',symbol:'R標',region:'華南地區',industry:'服飾鞋包',price:'5萬-10萬'}]目前已有的一個思路:lettemp=[];letcache;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);
大佬們遇到過這個問題嗎?如何實現用數組對數組進行篩選?怎么回事哈???
慕田峪7331174
2019-07-26 23:31:27