Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 967 Bytes

create-a-multiline-strings.mdx

File metadata and controls

32 lines (24 loc) · 967 Bytes
category created tags title
Tip
2021-04-13
JavaScript
Create a multiline strings

To create a multiline strings, the most common way is to concatenate them as shown below:

const multilineStrings = 'This is a\n' + 'multiline\n' + 'strings';

Joining an array of strings is another approach:

const multilineStrings = ['This is a', 'multiline', 'strings'].join('\n');

ES6 introduces an easier way to do that. It uses the template literal which is delimited by backticks:

const multilineStrings = `This is a
multiline
strings`;

See also