Lesson 7. Template literals

 

After reading lesson 7, you will

  • Know how to achieve string interpolation with template literals
  • Understand how to use multiline strings with template literals
  • Know how to make reusable templates with template literals
  • Understand how tagged template literals can add custom processing to template literals

In JavaScript, one of my biggest annoyances has always been the lack of support for multiline strings. Having to break each line into a separate string and glue them all together is a tedious process. With the addition of template literals, that pain is gone, along with some others. Template literals introduce multiline strings to JavaScript, as well as interpolation and tagging. Don’t worry if you’re unsure what these terms mean: I’ll explain each one.

7.1. What are template literals?

7.2. Template literals are not reusable templates

7.3. Custom processing with tagged template literals

Summary