Search⌘ K
AI Features

Tagged Templates

Explore how to create and use tagged template functions in JavaScript ES6 to manipulate template literals. Understand how these functions process string fragments and substitutions, enabling customized string formatting and dynamic content creation.

We'll cover the following...

A template tag is a function performing a transformation on a template literal, returning a string. The signature of a tag function is:

Node.js
tagFunction( literalFragments, ...substitutionValues )
  • literalFragments is an array of Strings that store fragments of the template literal. We use substitutions to split the original template literal.
  • the rest parameter ...substitutionValues contains the values of ${...} substitutions.
...