List of utility methods to do Array Has Duplicate
hasDuplicates()Array.prototype.hasDuplicates = function() { this.sort(); for (var i = 1; i < this.length; i++) { if (this[i - 1] == this[i]) { return true; return false; }; ... | |
hasDuplicates()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; | |
isDuplicate(val)Array.prototype.isDuplicate = function(val) { for (var i = 0; i < this.length; i++) { var currentVal = this[i]; if (currentVal === val) { return true; return false; |