How to break Javascript strings into multiple lines
There are two ways to break up a Javascript string into multiple lines: Backslashing and string concatenation.
String concatenation is often easier on your eyes, but slower and more memory intensive. If speed and performance is a goal than you should always delimit your JavaScript strings with backslashes and not plus signs.
Delimiting with backslashes
- var text = "Lorem ipsum dolor sit amet,\
- consectetur adipisicing elit,\
- sed do eiusmod tempor incididunt\
- ut labore et dolore magna aliqua.";
Delimiting with string concatenation
- var text = "Lorem ipsum dolor sit amet,"
- + "consectetur adipisicing elit,"
- + "sed do eiusmod tempor incididunt"
- + "ut labore et dolore magna aliqua.";
2 days ago
Photoshop Pro Tip: Edit –> Keyboard Shortcuts: Delete Help shortcut.
5 days ago
Self-driving cars now legal in Nevada. http://t.co/KJhEZmhG That’s one small step for man, one giant leap for Skynet.
5 days ago
Self-driving cars now legal in Nevada. http://t.co/KJhEZmhG That’s one small step for man, one giant leap for Skynet.
9 days ago
All URLs are URIs, but all URIs are not URLs.
11 days ago
“And I will always love you” It’s weird when people die.
11 days ago
“I believe that what doesn’t kill us makes us bitter.” Chuck Lorre vanity card 1. http://t.co/G6HJ1fUa
13 days ago
Backbone patterns is a great initiative. http://t.co/oFCGhyzd