How does array.filter((item, index) => array.indexOf(item) === index) work?
I'm aware the that filter method iterates over all the items in the array, but how does this method work when you add in index as a parameter too? Does it then iterate over entire set of pairs of (item, index)?
I'm trying to find the unique element in an array in which every element is duplicated apart from one. e.g. [1,1,2], [1,2,3,2,1], etc