Node.js examples for Array:Set Operation
Get array distinct and test
Array.prototype.distinct = function() { var ret = []; for (var i = 0; i < this.length; i++) {/*from w ww.j a va 2 s . com*/ for (var j = i+1; j < this.length;) { if (this[i] === this[j]) { ret.push(this.splice(j, 1)[0]); } else { j++; } } } return ret; } //test console.log(['a','b','c','d','b','a','e'].distinct());