jskatas.org Continuously Learn JavaScript. Your Way.

Template strings: basics

A template string, is wrapped in backticks.

Donate to NGO Julenka. Support Ukranians in need. Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.

A template string, is wrapped in ` (backticks) instead of ' or "

by default, behaves like a normal string

  • just surrounded by backticks

can evaluate variables, which are wrapped in "${" and "}"

  • e.g. a simple variable "${x}" just gets evaluated
  • multiple variables get evaluated too

can evaluate any expression, wrapped inside "${...}"

  • all inside "${...}" gets evaluated
  • inside "${...}" can also be a function call

Links

Description of template strings.
The specification describing the template string syntax.