Substring Java Script function (left and right)

There is no built in functions inside Jscript to extract left or right substring from specific string… the following functions are customized to do so..

function LeftSubString(stringValue, length)
{
if (length <= 0)
    return "";
else if (length > String(stringValue).length)
    return stringValue;
else
    return String(stringValue).substring(0,length);
}

function RightSubString(stringValue, length){
if (length <= 0)
    return "";
else if (length > String(stringValue).length)
    return stringValue;
else {
     var iLen = String(stringValue).length;
     return String(stringValue).substring(iLen, iLen – length);
    }
}