I found a solution to where I get returned an array of elements without duplicates:
Array1 = Array1.filter(function(val) { return Array2.indexOf(val) == -1; }); However, I want to modify this code just a little bit. Instead of being returned an array without duplicates, I want to do something when there is a duplicate. The problem is, I'm not sure how exactly this code works. The thing is I'm not sure how val gets set, or what it even is.
for (var i = 0; i < json.length; i++) { var item = json[i]; // if json.indexOf(val?), do something }