What I am trying to achieve is compare two arrays with image source strings and get the difference of that and store that in a new array.
Here is how I execute the function with two arrays as parameters
compareImgUrls(extractedResources, currentExtractedResources);
and this it the function:
function compareImgUrls(array1, array2) {
var a = [],
diff = [];
for (var i = 0; i < array1.length; i++) {
a[array1[i]] = true;
}
for (var i = 0; i < array2.length; i++) {
if (a[array2[i]]) {
delete a[array2[i]];
} else {
a[array2[i]] = true;
}
}
for (var k in a) {
diff.push(k);
}
console.log('diff', diff)
return diff;
}
But this returns an array with all strings behind each other and not the difference. How can I compare these arrays and delete the duplicated strings, and store the others in a new array.