Template Literals (ES6) Sample

Available in Chrome 41+

ES6 Template Literals are strings that can include embedded expressions. This is sometimes referred to as string interpolation.

Template Literals use back-ticks rather than the single or double quotes we're used to with regular strings. The template literal can contain placeholders using the ${ } syntax. The value populated in placeholders including the text between them gets passed to a function. This is determined on the expression before the template string. If no expression exists before the template literal, the default template is used.

This sample demonstrates creating and working with expression placeholders, expression interpolation, multi-line strings and functions inside expressions. We also look at tagged Template Literals.