Skip to content

Template literals · ⁨模板字符串⁩

English

A cleaner way to build strings

  • Wrap a string in backticks ` and you can drop values straight in with ${...}.
  • This is a template literal — much tidier than joining with lots of +.

中文

构建字符串的更整洁方式

  • 用反引号 ` 包住字符串,你就能用 ${...} 把值直接放进去。
  • 这叫模板字符串(template literal)—— 比用许多 + 拼接整洁多了。

模板字符串:每个 ${...} 都被它的值替换,拼出一个完整的字符串

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩