pinalbhatt
4/1/2014 - 3:25 AM

Multi-Line JavaScript Strings

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.  
*/