+ 1

Strings ( Java Script)

Strings (JS) has to be inside quotes thus quotes within stings has to be inside backslashes for the string to print ?

20th Feb 2017, 8:14 AM
Petra Buys
Petra Buys - avatar
4 Réponses
+ 5
In JavaScript you can use ' or " for strings. You don't need to escape these characters if you use the other one to declare the string: 'hi "Petra", how are you' "hi 'Petra', how are you" Of course you have to escape if you have to use the same character: 'hi \'Petra\', how are you' "hi \"Petra\", how are you"
20th Feb 2017, 8:30 AM
Tamás Barta
Tamás Barta - avatar
+ 4
Petra, your second sentence in JS should be: '\'or " seems practical' just for practice
20th Feb 2017, 8:55 AM
Tamás Barta
Tamás Barta - avatar
+ 3
Not "inside" backslashes, but PRECEDED BY one backslash... as for saying "hey, this quote is not the signal of the end of the string, it's inside it" to the parser ;)
20th Feb 2017, 8:52 AM
visph
visph - avatar
+ 1
'hi\'Tamas\'thank you!' 'or " 'seems practical'
20th Feb 2017, 8:49 AM
Petra Buys
Petra Buys - avatar