Function declared as variable "function is not defined" error in js
Hi,I got a sudden error in my web project. When i published it i am getting error on my js functions "Uncaught ReferenceError: ltrim is not defined"
In my js file:
ltrim = function(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
but when i changed it to as below and its working:
function ltrim (str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
Please help me how to resolve and why this issue has came.
Thanks
Anil