i am trying to filter the unique ones from a given array using filter method but its throwing an empty array, here is the code
function dual(a) {
  if (Array.isArray(a)) {
    let unique = a.filter((val, index) => {
      a.indexOf(val) == index
    })
    return unique;
  }
}
console.log(dual([3, 1, 1, 2, 2])) //expected result [3,1,2] but showing [] 
     
     
    