The most basic practice is to:
JS Code
- var str = "111\n222\n333";
But this is not good typesetting. JavaScript itself supports the "\" of the segmentation method, so you can write:
JS Code
- var str = "111\n\
- 222\n\
- 333 ";
But still uncomfortable, no one added a backslash. It is suggested that XML constructs are used, but editors with syntax highlighting are often confused by this notation.
An expert is everywhere, someone actually uses annotations. Personally think this is the most convenient. I changed it a bit:
JS Code
- Function.prototype.getMultiLine = function () {
- var lines = New String (this);
- Lines = lines.substring (Lines.indexof ("/*") + 3, Lines.lastindexof ("*/"));
- return lines;
- }
- var ffff = function () {
- /*
- Zhang San to pour water <br/>
- <strong> God! </strong>
- */
- }
- document.write (Ffff.getmultiline ());
This is a bit more, but it's worth it to keep multiple lines of text intact.
JS Multi-line string