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 |
---|