The question is:
What is the JavaScript method to store a multiline string into a variable like you can in PHP?
If by 'multiline string' you mean a string containing linebreaks, those can be written by escaping them using \n
(for newline):
var multilineString = 'Line 1\nLine 2';
alert(multilineString);
// Line 1
// Line 2
If you mean, how can a string be written across multiple lines of code, then you can continue the string by putting a \
backslash at the end of the line:
var multilineString = 'Line \
1\nLine 2';
alert(multilineString);
// Line 1
// Line 2
var es6string = `<div>
This is a string.
</div>`;
console.log(es6string);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With