here is my string:
var str = \"This is my \\string\";
This is my code:
var replaced = str.replace(\"/\\\\/\", \"\\\\\\\\\")
I haven't tried this, but the following should work
var replaced = str.replace((new RegExp("\s"),"\\s");
Essentially you don't want to replace "\", you want to replace the character represented by the "\s" escape sequence.
Unfortunately you're going to need to do this for every letter of the alphabet, every number, symbol, etc in order to cover all bases