--- id: javascript-string-templates title: "JavaScript String Templates" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["template strings", "template literals", "back-tics", "string interpolation", "ES6 strings"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.89 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["javascript", "js", "web", "frontend", "w3schools", "template-literals", "interpolation", "es6"] raw_sources: ["https://www.w3schools.com/js/js_string_templates.asp"] applied_in: [] github_commit: "" --- # [[JavaScript String Templates]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) Template strings use back-ticks instead of quotes, letting you embed both quote types, write multiline text, and interpolate variables and expressions with `${...}` β€” an ES6 feature supported in all modern browsers since June 2017. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Back-tics define the string** β€” template strings use back-ticks (`` ` ``) rather than the quotes (`"`) to define a string. [S1] - **Both quote types allowed inside** β€” template strings allow both single and double quotes inside a string. [S1] - **Multiline strings** β€” template strings allow multiline strings. [S1] - **Interpolation** β€” template strings allow variables in strings using the `${...}` syntax. [S1] - **Expression substitution** β€” template strings allow interpolation of expressions in strings. [S1] - **ES6 feature** β€” template strings are an ES6 feature; ES6 is fully supported in all modern browsers since June 2017. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Interpolate variables** β€” drop variables straight into text with `${variable}` instead of concatenating with `+`. [S1] - **Interpolate expressions** β€” compute inline, e.g. `${(price * (1 + VAT)).toFixed(2)}`. [S1] - **Build HTML templates** β€” assemble HTML by interpolating values and looping to append list items. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **Back-Tics Syntax** Template strings use back-ticks (`` ` ``) rather than the quotes (`"`) to define a string. [S1] ```javascript let text = `Hello World!`; ``` **Quotes Inside Strings** Template strings allow both single and double quotes inside a string. [S1] ```javascript let text = `He's often called "Johnny"`; ``` **Multiline Strings** Template strings allow multiline strings. [S1] ```javascript let text = `The quick brown fox jumps over the lazy dog`; ``` **Interpolation** Template strings allow variables in strings, using the `${...}` interpolation syntax. [S1] ```javascript let firstName = "John"; let lastName = "Doe"; let text = `Welcome ${firstName}, ${lastName}!`; ``` **Expression Substitution** Template strings allow interpolation of expressions in strings. [S1] ```javascript let price = 10; let VAT = 0.25; let total = `Total: ${(price * (1 + VAT)).toFixed(2)}`; ``` **HTML Templates** Template strings can be used to build HTML by interpolating values and looping over data. [S1] ```javascript let header = "Template Strings"; let tags = ["template strings", "javascript", "es6"]; let html = `

${header}

`; ``` **Browser Support** Template strings are an ES6 feature, fully supported in all modern browsers since June 2017. [S1] | Browser | Chrome | Edge | Firefox | Safari | Opera | |---------|--------|------|---------|--------|-------| | Version | 51 | 15 | 54 | 10 | 38 | | Date | May 2016 | Apr 2017 | Jun 2017 | Sep 2016 | Jun 2016 | ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's own snippets are the canonical applied examples β€” basic back-tick strings, embedded quotes, multiline text, variable and expression interpolation, and an HTML-building loop. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Interpolate variables: ```javascript let text = `Welcome ${firstName}, ${lastName}!`; ``` Interpolate an expression: ```javascript let total = `Total: ${(price * (1 + VAT)).toFixed(2)}`; ``` Build an HTML list: ```javascript let html = `

${header}

`; ``` ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) No contradictions found in the source. ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual (μ‹€μ œ 적용 사둀 발견 μ‹œ applied/validated둜 승격 κ°€λŠ₯) - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.89 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[JavaScript Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[JavaScript Strings]], [[JavaScript String Methods]], [[JavaScript ES6]], [[JavaScript Variables]] - **μ°Έμ‘° λ§₯락:** Referenced whenever building dynamic text or HTML from variables, replacing `+` concatenation. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” JavaScript String Templates β€” https://www.w3schools.com/js/js_string_templates.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript String Templates" page (Astra wiki-curation, P-Reinforce v3.1 format).