Here you can find the source of isDuplicate(val)
/**//from w ww . j a v a 2 s . c om * Test if a value is already contained in the array. * - Shallow search * - Compares primitives only * * return - True if the passed value is a already contained within the array, * False otherwise. */ Array.prototype.isDuplicate = function(val) { for (var i = 0; i < this.length; i++) { var currentVal = this[i]; if (currentVal === val) { return true; } } return false; } /* EOF */
Array.prototype.hasDuplicates = function() { this.sort(); for (var i = 1; i < this.length; i++) { if (this[i - 1] == this[i]) { return true; return false; }; ...
Array.prototype.hasDuplicates = function() { for (var i = 0; i < this.length; i++) { var currentVal = this[i]; for (var j = 0; j < this.length; j++) { if(i === j) continue; var val = this[j]; if (currentVal === val) { return true; return false;