JavaScript(JS) JS create multiline strings
In JavaScript, you can create multiline strings using template literals. To create a multiline string, you can use backticks (`) to enclose the string, and use the newline character (\n) to insert line breaks. Here is an example:
const multilineString = `This is a multiline string`;Sourcegi.www:iftidea.com
In the above example, the string is enclosed by backticks, and the newline character is used to insert line breaks between the words "This is a", "multiline", and "string".
Alternatively, you can also use string concatenation to create a multiline string, like this:
const multilineString = "This is a " + "multiline " + "string";
In this example, the string is split into multiple lines using the plus (+) operator, and the resulting string is the same as the previous example.
Note that in both examples, whitespace characters (e.g. spaces and tabs) are included in the resulting string. If you want to exclude whitespace characters from the string, you can use the trim() method to remove leading and trailing whitespace, like this:
const multilineString = ` This is a multiline string `.trim();