Here you can find the source of isUnique()
"use strict";// w ww . jav a 2s .c o m 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){ ...
Array.prototype.isUnique = function(value){ var idx = this.indexOf(value); return this.indexOf(value, idx + 1) == -1; };