0Pricing
JavaScript Academy · Lesson

Multiline Strings

Write readable multiline text without escapes.

The Old Way

Before template literals, a multiline string required explicit newline escape sequences or string concatenation across lines. This was verbose and error prone.

const old = "Line 1\nLine 2\nLine 3"
console.log(old)

Template Literals Span Lines

A template literal written with backticks can contain real line breaks in the source code. Every newline you type becomes a newline in the string.

The runnable example reproduces the same output using escape sequences.

const text = "First\nSecond\nThird"
console.log(text)

All lessons in this course

  1. String Interpolation Basics
  2. Multiline Strings
  3. Tagged Template Functions
  4. Practical Tagged Template Use Cases
← Back to JavaScript Academy