Skip to content

Instantly share code, notes, and snippets.

@pinalbhatt
Last active August 29, 2015 13:57
Show Gist options
  • Save pinalbhatt/9907132 to your computer and use it in GitHub Desktop.
Save pinalbhatt/9907132 to your computer and use it in GitHub Desktop.
Multi-Line JavaScript Strings
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