0
Why can't we put the quotation mark before the \?
document.write('Hello World! \' I'm a programmer. \')
3 Answers
+ 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âșïžâșïž.
+ 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.
0
thanks guys