I have two arrays
self.objarr = [
{ name: ' abc '},
{ name: ' def '},
{ name: ' xyz '}
];
self.strarr =[' abc ',' mno '];
I would like to find items in strarr which are not already present in objarr (in the above case 'mno').
UPDATE: Answer links were shown which had arrays of the same object style, so either both were string arrays or if both were objects, they had same style. But in my case, one is an object where the other is a string array. One of the answers was as below:
var x = ["a","b","c","t"];
var y = ["d","a","t","e","g"];
myArray = y.filter( function( el ) {
return x.indexOf( el ) < 0;
});
I tried something on same lines as below but it did not work:
myArray = self.strarr.filter(function (el) {
console.log(el);
return self.objarr.name.indexOf(el) < 0;
});
I'm reopening with hope that someone can help.