filmov
tv
[ES6] template strings II
![preview_player](https://i.ytimg.com/vi/E_q-by16hvE/maxresdefault.jpg)
Показать описание
[ES6] template strings II
Template literals are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them. They were called "template strings" in prior editions of the ES2015 specification.
Template literals are enclosed by the backtick (` `) character instead of double or single quotes. Template literals can contain placeholders. These are indicated by the dollar sign and curly braces (${expression}). The expressions in the placeholders and the text between the backticks (` `) get passed to a function. The default function just concatenates the parts into a single string. If there is an expression preceding the template literal, this is called a "tagged template". In that case, the tag expression (usually a function) gets called with the template literal, which you can then manipulate before outputting. To escape a backtick in a template literal, put a backslash \ before the backtick.
Template literals are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them. They were called "template strings" in prior editions of the ES2015 specification.
Template literals are enclosed by the backtick (` `) character instead of double or single quotes. Template literals can contain placeholders. These are indicated by the dollar sign and curly braces (${expression}). The expressions in the placeholders and the text between the backticks (` `) get passed to a function. The default function just concatenates the parts into a single string. If there is an expression preceding the template literal, this is called a "tagged template". In that case, the tag expression (usually a function) gets called with the template literal, which you can then manipulate before outputting. To escape a backtick in a template literal, put a backslash \ before the backtick.