Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let a = [{"sku":"a"},
- {"sku":"b"},
- {"sku":"c"},
- {"sku":"d"},
- {"sku":"e"},
- {"sku":"ff"},
- {"sku":"gg"}]
- let b = [{"sku":"k"},
- {"sku":"z"},
- {"sku":"d",'fig':3},
- {"sku":"b","fig":5},
- {"sku":"a"},
- {"sku":"c"}];
- let __KEY__ = Object.keys(a[0])[0]
- a.forEach((x,i)=> {
- let k = b.find(z=> z[__KEY__] == x[__KEY__])
- if(k) {
- a[i]._MATCHED = k[__KEY__]
- a[i] = {...a[i],...k}
- }
- });
- console.log(a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement