/ Published in: JavaScript
Thanks to the original author.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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; }
URL: http://stackoverflow.com/questions/1960473/unique-values-in-an-array/1961068#1961068