JavaScriptTemplate Literals


Introduction

Template literals are a type of string literal that allows values to be interpolated, and optionally the interpolation and construction behaviour to be controlled using a "tag" function.

Syntax

  • message = `Welcome, ${user.name}!`
  • pattern = new RegExp(String.raw`Welcome, (\w+)!`);
  • query = SQL`INSERT INTO User (name) VALUES (${name})`

Remarks

Template Literals were first specified by ECMAScript 6 §12.2.9.