why this gives 's as output? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

why this gives 's as output?

var str = '\' ' +'s' console.log(str) //output is 's

2nd Aug 2019, 1:29 PM
Danielov
Danielov - avatar
1 Answer
+ 3
You might ask why \ was not in output? It's because \ is a special character used to escape some characters, when \ escapes any character, it will not be printed. If you want to print \, you need to escape it's self by another blackslash, \\
2nd Aug 2019, 1:48 PM
Seb TheS
Seb TheS - avatar