0% found this document useful (0 votes)
2 views7 pages

JavaScript Template Strings

The document provides an overview of JavaScript Template Strings, which utilize back-ticks for string definition and support features like interpolation, multiline strings, and inclusion of both single and double quotes. It includes examples demonstrating variable and expression substitutions within template strings. Additionally, it notes that Template Strings are an ES6 feature supported by modern browsers since June 2017.

Uploaded by

josephsani730
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

JavaScript Template Strings

The document provides an overview of JavaScript Template Strings, which utilize back-ticks for string definition and support features like interpolation, multiline strings, and inclusion of both single and double quotes. It includes examples demonstrating variable and expression substitutions within template strings. Additionally, it notes that Template Strings are an ES6 feature supported by modern browsers since June 2017.

Uploaded by

josephsani730
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

10/11/25, 7:14 AM JavaScript Template Strings

 Tutorials  References  Exercises  Get Certified

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C

JavaScript String Templates


❮ Previous Next ❯

String Templates
Template Strings
Template Literals
Beloved child has many names

Back-Tics Syntax
Template Strings use back-ticks (``) rather than the quotes ("") to define a string:

Example

let text = `Hello World!`;

Try it Yourself »

[Link] 1/7
10/11/25, 7:14 AM JavaScript Template Strings

Quotes
 TutorialsInside
 Strings
References  Exercises  Get Certified

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
Template Strings allow both single and double quotes inside a string:

Example
let text = `He's often called "Johnny"`;

Try it Yourself »

Multiline Strings
Template Strings allow multiline strings:

Example
let text =
`The quick
brown fox
jumps over
the lazy dog`;

Try it Yourself »

REMOVE ADS

Interpolation
Template Strings allow variables in strings.

Template strings provide an easy way to interpolate variables in strings.

[Link] 2/7
10/11/25, 7:14 AM JavaScript Template Strings

 Tutorials 
Syntax
References  Exercises  Get Certified

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
${...}

Example
Variable Substitutions:

let firstName = "John";


let lastName = "Doe";

let text = `Welcome ${firstName}, ${lastName}!`;

Try it Yourself »

Expression Substitution
Template Strings allow interpolation of expressions in strings:

Example
let price = 10;
let VAT = 0.25;

let total = `Total: ${(price * (1 + VAT)).toFixed(2)}`;

Try it Yourself »

HTML Templates

Example
[Link] 3/7
10/11/25, 7:14 AM JavaScript Template Strings

let header = "Template Strings";


Tutorials  References  Exercises 
let tags = ["template strings", "javascript", "es6"];
Get Certified

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
let html = `<h2>${header}</h2><ul>`;
for (const x of tags) {
html += `<li>${x}</li>`;
}

html += `</ul>`;

Try it Yourself »

Browser Support
Template Strings is an ES6 feature.

ES6 is fully supported in all modern browsers since June 2017:

Chrome Edge Firefox Safari Opera


51 15 54 10 38

May 2016 Apr 2017 Jun 2017 Sep 2016 Jun 2016

Complete String Reference


For a complete String reference, go to our:

Complete JavaScript String Reference.

The reference contains descriptions and examples of all string properties and methods.

[Link] 4/7
10/11/25, 7:14 AM JavaScript Template Strings

❮ Previous
Tutorials  References  Exercises  Next ❯
Get Certified

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C

COLOR PICKER

 

REMOVE ADS

[Link] 5/7
10/11/25, 7:14 AM JavaScript Template Strings

 Tutorials  References  Exercises  Get Certified

HTML
 CSS
 JAVASCRIPT
PLUS
SQL PYTHON
SPACES
JAVA PHP HOW TO [Link] C

GET CERTIFIED FOR TEACHERS

FOR BUSINESS CONTACT US

Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial
SQL Tutorial
Python Tutorial
[Link] Tutorial
Bootstrap Tutorial
PHP Tutorial
Java Tutorial
C++ Tutorial
jQuery Tutorial

Top References
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
[Link] Reference
Bootstrap Reference
PHP Reference
HTML Colors
Java Reference
AngularJS Reference
jQuery Reference

Top Examples Get Certified


HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
[Link] Examples PHP Certificate
Bootstrap Examples jQuery Certificate
PHP Examples Java Certificate
Java Examples C++ Certificate
XML Examples C# Certificate
jQuery Examples XML Certificate

[Link] 6/7
10/11/25, 7:14 AM JavaScript Template Strings

 Tutorials  References  Exercises  Get Certified

HTML
 CSS JAVASCRIPT SQL
 PYTHON
  JAVA
 PHP HOW TO [Link] C

FORUM ABOUT ACADEMY


W3Schools is optimized for learning and training. Examples might be simplified to improve reading and
learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full
correctness
of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and
privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by [Link].

[Link] 7/7

You might also like