有一个二维数组和一个一维数组,根据一维数组提供的值,找到对应二维数组中的元素二维数组 数字是编号[ ["1","商务"], ["2","健身"], ["3","游泳"], ["4","餐饮"], ["5","休闲"], ["6","住宿"]][1,3,5]对应 ["1","商务"] ["3","游泳"] ["5","休闲"]
1 回答
皈依舞
TA贡献1851条经验 获得超3个赞
Array.prototype.myFilter=function(ary){
return this.filter(function(item){
return ary.indexOf(Number(item[0]))!=-1;
})
}
var a=[
["1","商务"],
["2","健身"],
["3","游泳"],
["4","餐饮"],
["5","休闲"],
["6","住宿"]
];
var b=[1,3,5];
console.log(a.myFilter(b))
添加回答
举报
0/150
提交
取消