Here you can find the source of uniq()
Array.prototype.uniq = function () { var dups = [];//from ww w . jav a 2s . c om for (var i = 0; i < this.length; i++) { var flag = true; for (var j = 0; j < dups.length; j++) { if (this[i] === dups[j]) { flag = false; } } if (flag) { dups.push(this[i]); } } return dups; } Array.prototype.two_sum = function () { var two_sums = []; for (var i = 0; i < this.length - 1; i++) { for (var j = i + 1; j < this.length; j++) { if (this[i] + this[j] === 0) { two_sums.push([i, j]); } } } return two_sums; } var my_transpose = function (array) { var matrix = []; for (var i = 0; i < array.length; i++) { sub_array = [] for(var j = 0; j < array.length; j++) { sub_array.push(array[j][i]); } matrix.push(sub_array); } return matrix; }
Array.prototype.uniq = function() { var uniq_array = []; for (var i=0; i<this.length; i++) { curr_ele = this[i] if (this.lastIndexOf(curr_ele) === i) { uniq_array.push(curr_ele); return uniq_array; ...
Array.prototype.uniq = function () { var sorted = this.sort(); var uniques = [sorted[0]]; for(var i = 1; i < sorted.length; i++) { if(sorted[i] !== sorted[i-1]) { uniques.push(sorted[i]); }; }; return uniques; ...
Array.prototype.uniq = function() { var results = []; for (var i = 0, len = this.length; i < len; i++) { var found = false; for (var j = 0, len2 = results.length; j < len2; j++) { if (this[i] === results[j]) { found = true; break; if (!found) { results.push(this[i]); return results; }; Array.prototype.uniq = function() { var results = []; for (var i = 0, len = this.length; i < len; i++) { if (results.indexOf(this[i]) < 0) { results.push(this[i]); return results; }; Array.prototype.uniq = function(sorted) { return this.inject([], function(array, value, index) { if (0 == index || (sorted ? array.last() != value : !array.include(value))) { array.push(value); return array; }); };
Array.prototype.uniq = function () { var occurrenceHash = {}; var result = []; for (var i = 0; i < this.length; i++) { if (!occurrenceHash[this[i]]) { occurrenceHash[this[i]] = true; result.push(this[i]); return result;
Array.prototype.uniq = function () { var results = []; for (var i = 0; i < this.length; i++) { var includes = false; for (var j = 0; j < results.length; j++) { if (results[j] === this[i]) { includes = true; }; ...
Array.prototype.uniq = function () { var flag = false; var result = []; for(var i=0;i<this.length;i++) { if(result.indexOf(this[i]) == -1) { if(this[i]==this[i]) { result.push(this[i]); else if(!flag) { ...
Array.prototype.uniq = function(){ var uniqArray = []; for (var i = 0; i < this.length; i++){ if (uniqArray.indexOf(this[i]) === -1) uniqArray.push(this[i]) return uniqArray ...
Array.prototype.uniq = function() { var temp = {}; for(var i=0; i<this.length; i++) { temp[this[i]] = 1; this.length = 0; for(var e in temp) { this.push(e); this.sort() return this; function xmlencode(string) { return string.replace(/\&/g,'&'+'amp;').replace(/</g,'&'+'lt;') .replace(/>/g,'&'+'gt;').replace(/\'/g,'&'+'apos;').replace(/\"/g,'&'+'quot;');
Array.prototype.uniq = function () { var uniq_arr = []; for (var i = 0; i < this.length; i++) { var included = false; for (var j = 0; j < uniq_arr.length; j++) { if (uniq_arr[j] === this[i]) { included = true; break; }; ...