title: JavaScript filter method not giving unique result
body: <p>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</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function dual(a) {
    if (Array.isArray(a)) {
      let unique = a.filter((val, index) =&gt; {
        a.indexOf(val) == index
      })
      return unique;
    }
  }
  console.log(dual([3, 1, 1, 2, 2])) //expected result [3,1,2] but showing []</code></pre>
  </div>
  </div>
  </p>