Tutorial by Examples

Template literals are a special type of string literal that can be used instead of the standard '...' or "...". They are declared by quoting the string with backticks instead of the standard single or double quotes: `...`. Template literals can contain line breaks and arbitrary expression...
The String.raw tag function can be used with template literals to access a version of their contents without interpreting any backslash escape sequences. String.raw`\n` will contain a backslash and the lowercase letter n, while `\n` or '\n' would contain a single newline character instead. const p...
A function identified immediately before a template literal is used to interpret it, in what is called a tagged template literal. The tag function can return a string, but it can also return any other type of value. The first argument to the tag function, strings, is an Array of each constant piece...
You can create an HTML`...` template string tag function to automatically encodes interpolated values. (This requires that interpolated values are only used as text, and may not be safe if interpolated values are used in code such as scripts or styles.) class HTMLString extends String { static e...
Template Literals act like strings with special features. They are enclosed by by the back-tick `` and can be spanned across multiple lines. Template Literals can contain embedded expressions too. These expressions are indicated by a $ sign and curly braces {} //A single line Template Literal v...

Page 1 of 1