Javascript - comparing two arrays by specific value and create a new array filled with matches -


please assume have 2 arrays filled objects this:

var arr1 = [{dog: "bark", cat: "meow", cow: "muh"}, {dog: "barking", cat: "meow", cow: "muhing"}] var arr2 = [{cat: "meow", dog2: "barked"}, {cow: "muhed", savage: "phew", cat: "meowed"}] 

i wish such output:

var arr3 = [{dog: "bark", cat: "meow", cow: "muh", dog2: "barked"}] 

i.e arr1 , arr2have common key value pair in objects, it's cat: "meow" , want these objects merged , pushed array, arr3 in case. possible? in advance!

please try this:

var _ = require('lodash');  var = [{a:1, b:2}]; var b = [{a:1, b:2, c:3}];  _.merge(a, b); 

//output: {a:1, b:2, c:3}

see if works you.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -