js 数组对照筛选
作者:互联网
var list = [{name:'zm',type:[2,3],age:'20'},{name:'dabao',type:[1,2,5],age:'22'}];
var sport = ['篮球','足球','羽毛球','高尔夫','棒球'];
console.log(list);
console.log(sport);
for(let i = 0;i<list.length;i++){
list[i].dd = [];
for(let j = 0;j<list[i].type.length;j++){
console.log(list[i].type[j]);
for(let k =0;k<sport.length;k++){
let o = '';
if(sport[k+1] == sport[list[i].type[j]]){
o = sport[k];
list[i].dd.push(o);
}
}
}
}
console.log(list);
标签:console,log,list,js,let,数组,筛选,sport,type 来源: https://www.cnblogs.com/zmzzr47/p/14324563.html