0

Why can't we put the quotation mark before the \?

document.write('Hello World! \' I'm a programmer. \')

4th Aug 2018, 7:44 AM
Jennifer Noland
Jennifer Noland - avatar
3 Respostas
+ 2
Strings are written in quotation marks => one indicates starting of string and another one for end of string. Suppose you want to use " in your string for example printf("Nice to "help" you"); Compiler will understand that you want to end string and will end it at beggining of help. So to include quotation mark in your string you have to use special character called back slash (\). It will tell compiler to consider it as special case and not end string , just add it to string. printf("Nice to \"help\" you"); Hope this explanation helps☺️☺️.
4th Aug 2018, 8:12 AM
Meet Mehta
Meet Mehta - avatar
+ 1
Which language are you talking about? JS: You can use single quotes for the entire string and double quotes in the inside and vice-versa. \" is used so that compiler doesn't get it confused with the end of the string as C/C++ uses \0 to stop reading a string.
4th Aug 2018, 7:48 AM
Akib
Akib - avatar
0
thanks guys
4th Aug 2018, 9:50 AM
Jennifer Noland
Jennifer Noland - avatar