Removing duplicate array values and then storing them [react]
<p>I'm trying to strip the duplicate array values from my current array. And I'd like to store the fresh list (list without duplicates) into a new variable. </p>

<pre><code>var names = ["Daniel","Lucas","Gwen","Henry","Jasper","Lucas","Daniel"];

const uniqueNames = [];
const namesArr = names.filter((val, id) =&gt; {
    names.indexOf(val) == id;  // this just returns true
});
</code></pre>

<p>How can I remove the duplicated names and place the non-duplicates into a new variable?</p>

<p>ie: uniqueNames would return...</p>

<pre><code>["Daniel","Lucas","Gwen","Henry","Jasper"] 
</code></pre>

<p>(I'm using react jsx) Thank you!</p>