2021年1月15日星期五

Create single array based on two arrays

I have two objects array:

    let arr1 = [          { id: "abdc4051", color: "red" },          { id: "abdc4052", color: "blue" }      ];        let arr2 = [          { uid: "abdc4051", name: "wall" },          { uid: "abdc4052", name: "kitchen" }          { uid: "abdc4053", name: "sofa" },          { uid: "abdc4054", name: "room" }      ];        

I need to make join by id and uid, according to example above I expect this result:

    let arr2 = [          { uid: "abdc4051", name: "wall",  color: "red" },          { uid: "abdc4052", name: "kitchen", color: "blue" }      ];        

I what the elegant way to do it in ES6?

https://stackoverflow.com/questions/65745890/create-single-array-based-on-two-arrays January 16, 2021 at 10:20AM

没有评论:

发表评论