by Sai gowtham

How to create multiline strings in JavaScript

In es6, JavaScript introduces a new way to create strings by using template literals where you can also create multiline strings.

To create a template literal, we need to use the backticks syntax (``) instead of double or single quotes.

Multiline strings example

let multi = `This
is a
Multiline
string.
`
let name = `this
is
a
big
multiline
string
`

Top Udemy Courses

JavaScript - The Complete Guide 2020 (Beginner + Advanced)
JavaScript - The Complete Guide 2020 (Beginner + Advanced)
45,614 students enrolled
52 hours of video content
View Course
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
284,472 students enrolled
40 hours of video content
View Course
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
130,921 students enrolled
48.5 hours of video content
View Course