What are template literals in JavaScript?

Answer

Template literals (ES6) are string literals enclosed in backticks (`) that support multi-line strings and embedded expressions. String interpolation: embed any expression with \${expression}`Hello, \${name}! You are \${age + 1} years old.`. Multi-line: template literals preserve newlines without needing \n. Tagged templates: a function can be placed before the template literal to process it — sql`SELECT * FROM users WHERE id = \${userId}`. The tag function receives the string parts as an array and the interpolated values separately, enabling safe SQL queries, styled components, or custom DSLs. Template literals are far more readable than string concatenation with + and are now the standard for all string building in modern JavaScript.