I am looping through an object and then upon each object I am comparing it to the items in my array in hopes to then push the objects that are not the same into my ItemsNotInObject array. Hopefully someone can shine some light on this for me. Thank you in advance.
var obj = {a:1, a:2, a:3};
var array = [1, 4, 2, 5, 6];
var ItemsNotInObject = [];
for (var prop in obj) {
for(var i = 0, al = array.length; i < al; i++){
if( obj[prop].a !== array[i] ){
ItemsNotInObject.push(array[i]);
}
}
}
console.log(ItemsNotInObject);
//output of array: 1 , 4 , 2 , 5, 6
//output desired is: 4 , 5 , 6
JSON
object. Make them uniqueobj[prop].a
,obj[prop]
isa
indexOf()
to check if the array contains the object property or not.