How to create multi-line strings in JavaScript?
There are several ways to create multi-line strings in JavaScript:
With ES6, the simplest option is to use template literals:var str = `This is a string
on several lines`;
With ES5, new lines can be escaped with \:
var str = 'This is a string \
on several lines';
Google JavaScript Style Guide recommends using string concatenation instead escaping new lines:
var str = 'This is a string ' +
'on several lines';
There are several ways to create multi-line strings in JavaScript:
With ES6, the simplest option is to use template literals:var str = `This is a string
on several lines`;
With ES5, new lines can be escaped with \:
var str = 'This is a string \
on several lines';
Google JavaScript Style Guide recommends using string concatenation instead escaping new lines:
var str = 'This is a string ' +
'on several lines';
| # | ID | Query | URL | Count |
|---|---|---|---|---|
| 0 | 13310 | alphons | https://en.ans.wiki/512/how-to-create-multi-minus-line-strings-in-javascript | 1 |
| 1 | 13055 | en | https://en.ans.wiki/512/how-to-create-multi-minus-line-strings-in-javascript | 8 |