Javascript String isUnique()
String.prototype.isUnique = function() { var lettersHash = {}; var nonUniqueLetters = ""; Array.prototype.map.call(this, function(x){ if(lettersHash[x]) { nonUniqueLetters += x//from w w w . j av a 2s. com } else { lettersHash[x] = true; } }); return nonUniqueLetters; } var nonUnique = "The cat is very bored."; var unique = "he was red"; console.log(nonUnique.isUnique());