Return to Snippet

Revision: 28501
at July 9, 2010 00:36 by riddla


Initial Code
Array.prototype.getUnique = function(){
   var u = {}, a = [];
   for(var i = 0, l = this.length; i < l; ++i){
      if(this[i] in u)
         continue;
      a.push(this[i]);
      u[this[i]] = 1;
   }
   return a;
}

Initial URL
http://stackoverflow.com/questions/1960473/unique-values-in-an-array/1961068#1961068

Initial Description
Thanks to the original author.

Initial Title
Unique array in JavaScript

Initial Tags
javascript, array

Initial Language
JavaScript