<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Comments on snippet: 'Remove Duplicate Values from Array'</title>
    <description>Snipplr comments feed</description>
    <link>https://snipplr.com/</link>
    <lastBuildDate>Tue, 07 Apr 2026 08:38:17 +0000</lastBuildDate>
    <item>
      <title>AlexWolfe said on 07/Dec/2010</title>
      <link>https://snipplr.com/view/45323/remove-duplicate-values-from-array</link>
      <description>&lt;p&gt;Would it be nice to set found = false; That way you could say if(found) newArr.push instead of if(!found). Both work, just seems like it would be more elegant.&#13;
&#13;
 Also, I'm not a big fan of setting vars to undefined. If you set a variable to undefined because if you don't even declare a var its returns undefined.&lt;/p&gt;</description>
      <pubDate>Tue, 07 Dec 2010 14:52:47 UTC</pubDate>
      <guid>https://snipplr.com/view/45323/remove-duplicate-values-from-array</guid>
    </item>
    <item>
      <title>AlexWolfe said on 07/Dec/2010</title>
      <link>https://snipplr.com/view/45323/remove-duplicate-values-from-array</link>
      <description>&lt;p&gt;Oops, scratch that. I read the code wrong. Sorry, !found definitely makes more sense because you are trying to avoid duplicates.&lt;/p&gt;</description>
      <pubDate>Tue, 07 Dec 2010 15:00:24 UTC</pubDate>
      <guid>https://snipplr.com/view/45323/remove-duplicate-values-from-array</guid>
    </item>
    <item>
      <title>ronydee said on 12/Dec/2010</title>
      <link>https://snipplr.com/view/45323/remove-duplicate-values-from-array</link>
      <description>&lt;p&gt;this function extends the Array object and cleans the duplicates from the input Array instead of creating a new one:&#13;
&#13;
Array.prototype.unique = function unique()&#13;
{&#13;
	var i = 0;&#13;
	while (i &lt; this.length)&#13;
	{&#13;
		var current = this[i];&#13;
		for (k = this.length; k &gt; i; k--)&#13;
		{&#13;
			if (this[k] === current)&#13;
			{&#13;
				this.splice(k,1);&#13;
			}&#13;
		}&#13;
		i++;&#13;
	}&#13;
	return this;&#13;
}&#13;
&#13;
var myarray = ['jeffrey', 'allie', 'patty', 'damon', 'zach', 'jeffrey', 'allie', 'patty', 'damon', 'zach', 'joe'];&#13;
alert(myarray.unique().join(', '));&lt;/p&gt;</description>
      <pubDate>Sun, 12 Dec 2010 04:24:28 UTC</pubDate>
      <guid>https://snipplr.com/view/45323/remove-duplicate-values-from-array</guid>
    </item>
    <item>
      <title>dvdrtrgn said on 14/Dec/2010</title>
      <link>https://snipplr.com/view/45323/remove-duplicate-values-from-array</link>
      <description>&lt;p&gt;Let's golf:&#13;
&#13;
`function unique(arr,dup) {&#13;
    dup = dup ? arr.concat() : arr;&#13;
    for (var i=0; i &lt; dup.length; i++) &#13;
        if (dup.indexOf(dup[i]) &lt; i) dup.splice(i--);&#13;
    return dup;&#13;
}`&lt;/p&gt;</description>
      <pubDate>Tue, 14 Dec 2010 16:29:31 UTC</pubDate>
      <guid>https://snipplr.com/view/45323/remove-duplicate-values-from-array</guid>
    </item>
  </channel>
</rss>
