Saturday, November 15, 2025
HomeLanguagesJavascriptHow to break JavaScript Code into several lines ?

How to break JavaScript Code into several lines ?

In this article, we will discuss how to break javascript code into several lines. We generally break the code into several lines so that it can be read easily by a third person or the programmer itself.

There are a few ways to break JavaScript code into several lines:

  • We can use the backslash \ character i.e “\”
  • We can use template literals.

We can use the addition operator.

Approach 1: Using Backslash \ character.

Javascript




// using \
console.log(
"let us see how to break lines in javascript, \
what can we do ?"
);


Output

let us see how to break lines in javascript, what can we do ?

Approach 2: Using the + operator:

Javascript




// using addition operator
let str = "This line is broken by " +
    "addition " +
    "operator"
 
 
console.log(str);


Output

This line is broken by addition operator

Approach 3: Using the template literals.

Javascript




// using template literals
let str = `
      This is a multiline
      string.
`;
 
console.log(str);


Output

      This is a multiline
      string.
RELATED ARTICLES

Most Popular

Dominic
32399 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6765 POSTS0 COMMENTS
Nicole Veronica
11917 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11984 POSTS0 COMMENTS
Shaida Kate Naidoo
6889 POSTS0 COMMENTS
Ted Musemwa
7143 POSTS0 COMMENTS
Thapelo Manthata
6838 POSTS0 COMMENTS
Umr Jansen
6840 POSTS0 COMMENTS