Javascript: String trim functions: leftTrim, rightTrim and trimAll


The first is a definition of the separate function leftTrim, rightTrim and trimAll.
These trim the spaces to the left of the string, the right of the string and both sides respectively.
function leftTrim(sString) 
{
    while (sString.substring(0,1) == ' ')
    {
    sString = sString.substring(1, sString.length);
    }
    return sString;
}
function rightTrim(sString) 
{
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
    sString = sString.substring(0,sString.length-1);
    }
    return sString;
}

function trimAll(sString) 
{
    while (sString.substring(0,1) == ' ')
    {
    sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
    sString = sString.substring(0,sString.length-1);
    }
    return sString;
}
I also noticed that Firefox was working with 'trim', ltrim and rtrim but IE wasn't. 
So I got these functions in and they worked for me in both.