I am sure this question will have be asked before but for some reason i can't find the right way to find the answer I'm after.
I have two lists of objects. The objects are slightly different but both have a 'ref' property that i can compare them with. I basically want a new list of objects that contains only the objects that are in list1 with a ref value that does not equal any of the ref values for objects in list2.
Currently this is the method I use. This does work. However I know that this is probably very inefficient since I am using two loops and looping through the second one countless times. So I'm wondering what the 'proper' method of doing this would be.
var add;
for (var x = 0; x < availableQuestions.length; x++) {
add = true;
for (var j = 0; j < currentQuestions.length; j++) {
if (availableQuestions[x].Ref == currentQuestions[j].Ref) {
add = false;
}
}
if (add) {
$scope.Questions.push(availableQuestions[x])
}
}