title: Understanding indexOf and lastIndexOf
body: <p>I'am doing some JavaScript exercises and I stumbled upon this one "Write a JavaScript program to filter out the non-unique values in an array."</p>
  
  <p>I tried and found a solution, which worked but it was to cumbersome. A better answer, according to the site, is the following:</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>const filter_Non_Unique = arr =&gt;
    arr.filter(l =&gt; arr.indexOf(l) === arr.lastIndexOf(l));
  
  console.log(filter_Non_Unique([1,2,3,4,4,5,6,6])) // 1,2,3,5</code></pre>
  </div>
  </div>
  </p>
  
  <p>Now I recked my head trying to understand why this solution works but I still don't get it.
  Can somebody explain to me? 
  Thanks in advance.</p>