Javascript String uniqueChars()

Description

Javascript String uniqueChars()

String.prototype.uniqueChars = function() {
    var u = {},/*from  w w w. jav a2 s  .  co  m*/
        a = [];
    for (var i = 0; i < this.length; i++) {
        if (u.hasOwnProperty(this[i])) {
            continue;
        }
        a.push(this[i]);
        u[this[i]] = 1;
    }
    return a;
}



PreviousNext

Related