Here you can find the source of isUnique(value)
/**//from w w w . j a v a2 s. co m * Array#isUnique(value) -> Boolean * returns true if a specified value is unique in an array * (or if it's not in an array) * * [1,2,3].isUnique(1); // true * [1,2,3,1].isUnique(1); // false * [5,6,'a'].isUnique('foo'); // true * **/ Array.prototype.isUnique = function(value){ var idx = this.indexOf(value); return this.indexOf(value, idx + 1) == -1; };
"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; };
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){ ...