List of utility methods to do Array Distinct
distinct(comparer)Array.prototype.distinct = function (comparer) { var arr = []; var l = this.length; for (var i = 0; i < l; i++) { if (!arr.contains(this[i], comparer)) arr.push(this[i]); return arr; }; ... | |
distinct2()Array.prototype.distinct2 = function(){ var _self = this; var _a = this.concat().sort(); console.log(_a); _a.sort(function(a,b){ console.log("a: "+ a, "b: "+ b); if(a == b){ var n = _self.indexOf(a); _self.splice(n, 1); ... |