Node.js examples for Array:Unique Element
Get unique element from array
Array.prototype.getUnique = function(){ var u = {}, a = []; for(var i = 0, l = this.length; i < l; ++i){ if(u.hasOwnProperty(this[i])) { continue;//from ww w. j av a2 s . c o m } a.push(this[i]); u[this[i]] = 1; } return a; }