I’m trying to use a back slash in console.log() and within <p></p> but it seems that when the page loads, all back slashes are removed.
Example JS
console.log('\m/ Lets rock. \m/');
Result
m/ Lets rock. m/
How can I prevent it from being removed?
EDIT: Backslash not forward slash. Running this on node.js with express, within the <head> tags of layout.jade. Backslash visible in REPL, but not when running on node in the web browser (Chrome & Firefox).
If
m/ Lets rock. m/is your result, I see forward slashes.If you mean backslashes, escape them to show that the string wants a literal backslash:
Otherwise, JavaScript interprets this as a
\mEscapeSequence. That’s why you need the\\EscapeSequence.The solution was that the backslashes needed to be double escaped:
…apparently the backslashes are processed as escaped characters twice (once in the initial string creation, then again for some other purpose).
So the string creation gives us:
…then the subsequent processing results in: