javascript multiline string 1

javascript multiline string

// OPTION 1
var MultilineString = `This
is 
a multiline 
string`; // Note: use the template quotation marks above the tab key

// OPTION 2
var MultilineString = 'This \n\
is \n\
a multiline \n\
string'; // Note: use the "\n\" as a newline character

Here is what the above code is Doing:
1. The first line of the string is assigned to the variable MultilineString.
2. The second line of the string is appended to the first line, separated by a newline character.
3. The third line of the string is appended to the second line, separated by a newline character.
4. The fourth line of the string is appended to the third line, separated by a newline character.

Similar Posts