Left trim an array using for loop - Node.js String

Node.js examples for String:Trim

Description

Left trim an array using for loop

Demo Code

String.prototype.lTrim = function(){
  str = this;//from   w ww .  j av  a2  s.co  m
   var i;
    for(i=0;i<str.length;i++)
    {
        if(str.charAt(i)!=" "&&str.charAt(i)!=" ")break;
    }
    str=str.substring(i,str.length);
    return str;
}

Related Tutorials