• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
October 21, 2022 |600 Views

Javascript program to create multi-line strings

  Share   Like
Description
Discussion

In this video, we will write a Javascript program to create multiline strings.

As we know, the multi-line strings were not supported by JavaScript, but a new version of ES6 came out and introduced a string literal facility.A ES6 supports multi-line strings.

Here in this video, we will see 3 different methods for creating a multiline strings in Javascript:
Method 1: Using template literals
Method 2: Using a backslash
Method 3: Using concatenating the individual strings together [+ operator]


Using template literals: In the first method, a multiline-strings are created by using template literals. The strings are delimited using backticks, unlike normal single & double quotes delimiter.

Using backslash: Here we use a backslash to escape the literal newlines. A backslash used to create multi-line strings is escaping every newline on each line.

Using concatenating the individual strings together [+ operator]: In this method, by using concatenating the individual strings together we can create a multiline in Java script.

Create multiline strings in JS:
https://www.geeksforgeeks.org/how-to-create-multi-line-strings-in-javascript/