How the filter() works here? Couldn't understand the filtering part

Tell us what’s happening:

Your code so far


unction uniteUnique() {
var concatArr = [];
var i = 0;
while (arguments[i]) {
  concatArr = concatArr.concat(arguments[i]);
  i++;
}
uniqueArray = concatArr.filter(function(item, pos) {
  return concatArr.indexOf(item) == pos;
});
return uniqueArray;
}

// test here
uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0.

Challenge: Sorted Union

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

The more information you give us, the more likely we are to be able to help.

This article from MDN might help you understand what filter does.