Create a multiline string in JavaScript

Today, you will learn how to create a multiline string in JavaScript. There are three different ways to write a mulitline string in JavaScript.

Ways to create a multiline string in JavaScript

  1. Using + operator
  2. Using \ operator
  3. Using template literal

1. Using + operator

The + operator and \n are used to produce a multiline string in the above example. The line is broken by the escape character \n.

2. Using \ operator

In the above example, a multiline string is created using . \n is used to break the line.

3. Using template literal

In the above example, the template literal is used to write multiline strings. The template literal was introduced in the newer version of JavaScript (ES6).

That’s it for today.
Thank you for reading. Happy Coding..!! đŸ™‚

If you found value in this article,
you can support us by buying me a coffee! ☕

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *