Example 1: Create Multiline Strings Using +
Output
This is a long message that spans across multiple lines in the code.
In the above example, a multiline string is created using the + operator and \n.
The escape character \n is used to break the line.
Example 2: Create Multiline Strings Using \
Output
This is a long message that spans across multiple lines in the code.
In the above example, a multiline string is created using \. \n is used to break the line.
Example 3: Create Multiline Strings Using Template Literal
Output
This is a long message that spans across multiple lines in the code.
In the above example, the template literal ` ` is used to write multiline strings.
The template literal was introduced in the newer version of JavaScript (ES6).
Some browsers may not support the use of template literals. To learn more, visit JavaScript Template Literal Support.