Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Multiline Strings | JavaScript syntax
Introduction to JavaScript (staging)
course content

Contenido del Curso

Introduction to JavaScript (staging)

Introduction to JavaScript (staging)

1. Introduction
2. JavaScript syntax
3. Data Types and Variables

bookMultiline Strings

What are multi-line strings?

This is a string that comes on more than one line. In JavaScript you may come across a situation where you have to store a multi-line string in a variable in your JavaScript. Strings that can not be shortened.

Following are the ways to get multi-line strings:

  • Multi-line strings using template literals.
  • Multi-line strings using a backslash.
  • Multi-line strings using concatenating multiple lines.

Multi-line strings using template literals:

we can use template literals that use backticks to define multiline strings and for expression evaluation in too in strings.

12345
let myStr = `This is my multiline String which is amazing`; console.log(myStr);
copy

Multi-Line Strings using Backslash:
Adding a backslash at the end of every line in a multiline string works, too. This can be a bit confusing as we are adding a special symbol to escape the new line character.

1234
let myStr = "This is my \ multiline String \ and it is amazing"; console.log(myStr);
copy

Tarea

You are given a string variable name foxJump. Your task is to split the string into three lines using backticks and display the output.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 12
toggle bottom row

bookMultiline Strings

What are multi-line strings?

This is a string that comes on more than one line. In JavaScript you may come across a situation where you have to store a multi-line string in a variable in your JavaScript. Strings that can not be shortened.

Following are the ways to get multi-line strings:

  • Multi-line strings using template literals.
  • Multi-line strings using a backslash.
  • Multi-line strings using concatenating multiple lines.

Multi-line strings using template literals:

we can use template literals that use backticks to define multiline strings and for expression evaluation in too in strings.

12345
let myStr = `This is my multiline String which is amazing`; console.log(myStr);
copy

Multi-Line Strings using Backslash:
Adding a backslash at the end of every line in a multiline string works, too. This can be a bit confusing as we are adding a special symbol to escape the new line character.

1234
let myStr = "This is my \ multiline String \ and it is amazing"; console.log(myStr);
copy

Tarea

You are given a string variable name foxJump. Your task is to split the string into three lines using backticks and display the output.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 12
toggle bottom row

bookMultiline Strings

What are multi-line strings?

This is a string that comes on more than one line. In JavaScript you may come across a situation where you have to store a multi-line string in a variable in your JavaScript. Strings that can not be shortened.

Following are the ways to get multi-line strings:

  • Multi-line strings using template literals.
  • Multi-line strings using a backslash.
  • Multi-line strings using concatenating multiple lines.

Multi-line strings using template literals:

we can use template literals that use backticks to define multiline strings and for expression evaluation in too in strings.

12345
let myStr = `This is my multiline String which is amazing`; console.log(myStr);
copy

Multi-Line Strings using Backslash:
Adding a backslash at the end of every line in a multiline string works, too. This can be a bit confusing as we are adding a special symbol to escape the new line character.

1234
let myStr = "This is my \ multiline String \ and it is amazing"; console.log(myStr);
copy

Tarea

You are given a string variable name foxJump. Your task is to split the string into three lines using backticks and display the output.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

What are multi-line strings?

This is a string that comes on more than one line. In JavaScript you may come across a situation where you have to store a multi-line string in a variable in your JavaScript. Strings that can not be shortened.

Following are the ways to get multi-line strings:

  • Multi-line strings using template literals.
  • Multi-line strings using a backslash.
  • Multi-line strings using concatenating multiple lines.

Multi-line strings using template literals:

we can use template literals that use backticks to define multiline strings and for expression evaluation in too in strings.

12345
let myStr = `This is my multiline String which is amazing`; console.log(myStr);
copy

Multi-Line Strings using Backslash:
Adding a backslash at the end of every line in a multiline string works, too. This can be a bit confusing as we are adding a special symbol to escape the new line character.

1234
let myStr = "This is my \ multiline String \ and it is amazing"; console.log(myStr);
copy

Tarea

You are given a string variable name foxJump. Your task is to split the string into three lines using backticks and display the output.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 2. Capítulo 12
Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
some-alt