Files
it-know-how/typescript/bits/09-template-literals.md
T
2026-03-27 12:58:01 +01:00

479 B
Executable File

Template Literals

Template literals are strings enclosed by backticks and support interpolation.

Syntax

const year = '2026';
const month = '03';
const day = '24';

const label = `${year}-${month}-${day}`;
console.log(label); // '2026-03-24'

Why use them

  • Easier than concatenation.
  • More readable for multi-part strings.
  • Supports multiline text.

Python Comparison

Equivalent concept to Python f-strings:

label = f"{year}-{month}-{day}"