I have a function f similar to
function f(str){
alert(\"abc\"+str);
}
Now, I want to use JavaScript special charecter \"\\b\" in such a
Something like this:
function f(str, abc){
if(!abc) abc = "abc";
if (str.indexOf("\b") != "undefined")
{
abc = abc.slice(0,-1);
str = str.replace("\b","");
f(str, abc);
}
else alert(abc+str);
}
and as an added bonus you get to use recursion!
note that this is a little slower than doing it this way:
function f(str){
var count = 0;
var abc = "abc";
for(var i = 0; i < str.length; i++)
{
if(str[i] = "\b") //at least i think its treated as one character...
count++;
}
abc = abc.slice(0, count * -1);
alert(abc+str);
}