F
freelance71
I have to pass the string '\abcd' to a function. Ofcourse one (or two) extra
'\' is needed to escape but experimenting with it shows that I have to pass
three extra backslashes to make it work.
<script>
var q = "\\\\abcd";
displayLatex(q);
</script>
/* this function is in another file */
function displayLatex(q) {
alert(q); /* this shows \abcd when called by above script*/
}
Can anyone explain why this is so? why 4 backslashes?
'\' is needed to escape but experimenting with it shows that I have to pass
three extra backslashes to make it work.
<script>
var q = "\\\\abcd";
displayLatex(q);
</script>
/* this function is in another file */
function displayLatex(q) {
alert(q); /* this shows \abcd when called by above script*/
}
Can anyone explain why this is so? why 4 backslashes?