Skip to content
Advertisement

Display n and rn characters in Dev Tools of a browser

In JavaScript, I have strings including newlines such as var s = "123n456" or var s = "123rn456".

Using console.log(s), the dev tools of a browser displays real newlines in console.

I would like to know how to print literally the string. For instance, I want to see 123n456 or 123rn456 in dev tools or a browser.

Could anyone help?

Advertisement

Answer

you could console.log(JSON.stringify(s))

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement