You can use do this:
var array1 = [0, 1, 2, 3, 4, 5, 6];
var array2 = [7, 8, 1, 2, 9, 10];
/* run a filter function for every value in array2 and returned the final filtered array */
var array3 = array2.filter(function(currentValue, index, arr){
return (array1.indexOf(currentValue) === -1); /* this will check whether currentValue exists in aray1 or not. */
});
console.log(array3) /* filtered array */
This should deliver what you want. Or another way:
var array1 = [0, 1, 2, 3, 4, 5, 6];
var array2 = [7, 8, 1, 2, 9, 10];
var duplicateRemoved = [];
/* run a function for every value in array2 and collect the unique value in a new array */
array2.forEach(function(currentValue, index, arr){
if (array1.indexOf(currentValue) === -1) {
duplicateRemoved.push(currentValue);
}
});
console.log(duplicateRemoved)
This should work in your situation unless there are some other external factors associated with it.