JavaScript: Multiline Strings in Source Code
Tip by Progger99 | 2014-01-25 at 13:18
Sometimes, for reasons of clarity, it is a good idea to let a string go over multiple lines.
In JavaScript, it is not readily possible to break a string in source code just using a line break.
Unless you are using a backslash at the end of each line:
document.write("This is a text,\ reaching over two lines.");
If you close a long string with a backslash, you can simply continue the string in the next line without any problems.
Incidentally, this kind of line break "within" the string is ignored and does not have any impacts to the string. It is just the same result as if you have written the string into one line.
About the Author
The author has not added a profile short description yet.
Show Profile
Related Topics
How to Replace multiple Texts at the same Time
Tutorial | 0 Comments
Rewrite Text Files with a fixed Line Length
Tutorial | 0 Comments
Repair Text Files with mixed Line Breaks
Tutorial | 0 Comments
Remove Spaces from the Beginning and End of the Lines of Texts
Tutorial | 0 Comments
PHP: Sending an E-Mail
Tutorial | 0 Comments
Delphi: Multiline Caption for TLabel (at Run Time and Design Time)
Tutorial | 1 Comment
jQuery: Assign Action to Keyboard Keys (Keyboard Event)
Tip | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.