The backslash '\' in console.log () does not appear

I'm trying to use backslashes in console.log()and inside <p></p>, but it seems that when the page loads, all backslashes are removed.

JS example

console.log('\m/ Lets rock. \m/');

Result

m/ Lets rock. m/

How can I prevent it from being deleted?

EDIT: The backslash is not a slash. Doing this on node.js with an expression in tags <head> layout.jade. The backslash is displayed in REPL, but not when working in node in a web browser (Chrome and Firefox).

+5
source share
6 answers

If m/ Lets rock. m/- your result, I see slashes.

, , , :

console.log('\\m/ Lets rock. \\m/');

JavaScript \m EscapeSequence. \\ EscapeSequence.


, :

console.log('\\\\m/ Lets rock. \\\\m/');

... , ( , - ).

, :

'\\m/ Lets rock. \\m/'

..., :

'\m/ Lets rock. \m/'
+12

console.log("\\m/ Lets rock. \\m/");
0

\ escape-. .

console.log('\\m/ Lets rock. \\m/');
0
0

Escape \ \ ( , \\ )

console.log('\\.m/ Javascript logging rocks!!! \\.m/');

'm' , . \.m/, \m/

0

You need to avoid backslashes with \, so you should just use \\instead \.

0
source

All Articles