Last active
August 29, 2015 13:57
-
-
Save pinalbhatt/9907132 to your computer and use it in GitHub Desktop.
Multi-Line JavaScript Strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var multiStr = "This is the first line" + | |
"This is the second line" + | |
"This is more..."; | |
//Alternate way to create multiline strings | |
var multiStr = "This is the first line \ | |
This is the second line \ | |
This is more..."; | |
/* | |
Adding a backslash at the end of each line tells the JavaScript engine that the string will | |
continue to the next line, thus avoiding the automatic semicolon insertion annoyance. | |
Note that int this second way, string includes line breaks within the string itself. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment