Simon Dubek
Simon Dubek

Reputation: 350

How to disable special newline and other characters in js strings

I am creating a simple string but all my letters after backslashes are being interpretted as special tags. Example:

const string = "C:\Users"
console.log(string)

The \U doesnt get printed in the final string so the console output looks like this: C:sers. How would I go about fixing this?

Upvotes: 0

Views: 30

Answers (1)

axtck
axtck

Reputation: 3965

You can escape these characters by adding an extra \

const path =  "C:\\users";

console.log(path)

Upvotes: 1

Related Questions