Unique Array for dates Javascript
<p>I see this question asked quite often for regular javascript arrays, however none of the answers seems to work if its an array of dates.</p>

<p>I can likely figure this out through trial an error but I do see some benefit to others if I ask.</p>

<p>Basically if you have a javascript array of dates that might have duplicates and need to filter into an array with no duplicates what is the best way to go about that?</p>

<p>I have tried the ES6 solution of <code>Array.from(new Set(arr))</code> but it just returns the same array.</p>

<p>Also I tried</p>

<pre><code>Array.prototype.unique = function() {
    var a = [];
    for (var i=0, l=this.length; i&lt;l; i++)
        if (a.indexOf(this[i]) === -1)
            a.push(this[i]);
    return a;
}
</code></pre>

<p>both came from <a href="https://stackoverflow.com/questions/1960473/unique-values-in-an-array">Unique values in an array</a></p>

<p>However neither worked, looks like <code>indexOf</code> does not work on date objects.</p>

<p>Here is how my array is generated atm</p>

<pre><code>//this is an array generated from ajax data, 
//its a year over year comparison with a separate year, 
//so to create a reliable date objects I force it to use the same year.
data.map(d =&gt; {
   dp = new Date(Date.parse(d.date + '-' + d.year));
   dp.setFullYear(2000);
   return dp;
})
</code></pre>

<p>It is about 100 or so different days, but it always ends up with about 350 index's.</p>