Node.js examples for Array:Remove Element
Eliminate all non-unique elements from an Array
/**/*ww w . j a v a 2s . c om*/ * Eliminate all non-unique elements from an Array * * @return {Object} unique element * */ Array.prototype.unique = function() { var u = []; o:for (var i=0, n=this.length; i<n; i++) { for (var x=0, y=u.length; x<y; x++) { if (u[x] == this[i]) { continue o; } } u[u.length] = this[i]; } return u; };