Multiline strings in JavaScript
Find out how to create multiline strings in JavaScript. In this post we will learn various ways to create multiline strings in JavaScript. One of the ways is Template Strings which waswas introduced in ES6.
Escape new lines using \
const multilineString = 'Hello This is Poopcode.\ We write bytesized posts about trending programming stuff.\ Anything else?'
Concatenating strings
const multilineString = 'Hello This is Poopcode.' + + 'We write bytesized posts about trending programming stuff.' + 'Anything else?'
Template Strings
Instead of using ‘ or “, use ` (backtick) to create strings which enables us to create multiline strings.
const multilineString = `Hello This is Poopcode. We write bytesized posts about trending programming stuff. Anything else?`