List of utility methods to do Array Unique Check
isUnique()"use strict"; Array.prototype.isUnique = function(){ var that = this; var result = true; for (var i = 0; i < that.length; i++){ for (var j = i+1; j < that.length; j++){ if(that[i] === that[j]){ result = false; return result; }; | |
isUnique(obj)function rand(min, max){ min = min || 0; max = max || 1; return Math.random() * (max - min) + min; }; exports.randInt = function(min, max){ return Math.floor( rand( min, max ) ); }; Array.prototype.isUnique = function(obj){ ... | |
isUnique(value)Array.prototype.isUnique = function(value){ var idx = this.indexOf(value); return this.indexOf(value, idx + 1) == -1; }; |