myArray = [{'id':'73','foo':'bar 22'},
{'id':'45','foo':'bar'},
{'id':'46','foo':'area'},
{'id':'47','foo':'line'}]
var allbars = myArray && myArray.filter(function( obj ) {
return obj.foo == "bar";
});
After filtering i am able to get
allbars = [{'id':'45','foo':'bar'}]
but i need all bars exists in the foo key
Expected output is(in the key foo i have bar, bar22 both are expecting in the output but i can able to get only bar)
allbars = [{'id':'45','foo':'bar'}, {'id':'73','foo':'bar 22'}]