JavaScript Template Strings
JavaScript Template Strings
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C
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 »
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C
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 »
Interpolation
Template String provide an easy way to interpolate variables and expressions into strings.
${...}
Variable
Tutorials Substitutions
Exercises Services Sign Up Log in
HTML CSS
Template StringsJAVASCRIPT
allow variables inSQL
strings: PYTHON JAVA PHP HOW TO W3.CSS C C++ C
Example
Try it Yourself »
Expression Substitution
Template Strings allow expressions in strings:
Example
let price = 10;
let VAT = 0.25;
Try it Yourself »
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C
Example
let header = "Template Strings";
let tags = ["template strings", "javascript", "es6"];
html += `</ul>`;
Try it Yourself »
Browser Support
Template Strings is an ES6 feature (JavaScript 2015).
May 2016 Apr 2017 Jun 2017 Sep 2016 Jun 2016
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C
❮ Previous Next ❯
W3schools Pathfinder
Track your progress - it's free! Sign Up Log in
COLOR PICKER
SQL Tutorial
Tutorials Exercises
Python Tutorial
W3.CSS Tutorial
Services Python Reference
W3.CSS Reference
Bootstrap Reference
Sign Up Log in
HTML
CSS Bootstrap Tutorial
JAVASCRIPT SQL PYTHON PHP Reference PHP
JAVA HOW TO W3.CSS C C++ C
PHP Tutorial HTML Colors
Java Tutorial Java Reference
C++ Tutorial Angular Reference
jQuery Tutorial jQuery Reference
Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.