原理:使用两个for循环进行循环判断
var list = [
{ code: 101, name: "aa" },
{ code: 103, name: "bb" },
{ code: 1001, name: "cc" },
{ code: 1011, name: "cc" }];
var list1 = [
{ name: "dj", age: 1001 },
{ name: "zs", age: 1011 },
{ name: "ww", age: 101 },
{ name: "wj", age: 103 }];
var list2 = [];
list.forEach(val => {
let aa = list1.find(value => {
return value.age == val.code;
})
list2.push(aa);
})
console.log(list2);
网友评论