Javascript String trimLeftChar()

Description

Javascript String trimLeftChar()


function trimLeftChar(trimChar) {
    var i, stop;
    var s = this.split('');

    for (i=0; i<s.length;i++){
        if (s[i] != trimChar) { 
            stop = i;/*w  w w .j a  va2s  .  c  om*/
            break;
        }
    }
    s.splice(0,i);
    return s.join('');
}

String.prototype.trimLeftChar = trimLeftChar;

module.exports = {
    trimLeftChar : trimLeftChar,
};



PreviousNext

Related