##The operating environment of this tutorial: windows7 System, ECMAScript version 6, Dell G3 computer. Template string (template string) is an enhanced version of the string, identified by backtick (`). It can be used as an ordinary string, or it can be used to define multi-line strings, or to embed variables in strings.es6 Usage of backticks: 1. Define a single-line string; 2. Define a multi-line string. The spaces, indents and newlines in the string will be retained in the output; 3. In the string Embed variables in "${}", for example "`Hello ${name}`"
// 字符串中嵌入变量 var name = "Bob", time = "today"; `Hello ${name}, how are you ${time}?`
var greeting = `\`Yo\` World!`;
$('#list').html(` <ul> <li>first</li> <li>second</li> </ul> `);
$('#list').html(` <ul> <li>first</li> <li>second</li> </ul> `.trim());
${}.
javascript video tutorial, web front-end】
The above is the detailed content of How to use backticks in es6. For more information, please follow other related articles on the PHP Chinese website!