Template Literals & String.raw in JavaScript
From the JavaScript String Methods cheat sheet · String Formatting · verified Jul 2026
Template Literals & String.raw
Use template literals for string interpolation and String.raw for raw strings
javascript
// Template literals
const name = 'World'
const greeting = `Hello, ${name}!` // 'Hello, World!'
// Multiline strings
const html = `
<div>
<h1>${name}</h1>
</div>
`
// String.raw - no escape processing
const path = String.raw`C:\Users\Documents` // Preserves backslashes💡 Template literals are the modern way to build strings
⚡ String.raw preserves escape sequences literally
📌 Tagged templates enable DSLs and string processing
✅ Use String.raw for Windows paths and regex patterns