Since ES6, you can use template literals:

const age = 3
console.log(`I'm ${age} years old!`)

P.S. Note the use of backticks: ``.

Answer from Damjan Pavlica on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Template_literals
Template literals (Template strings) - JavaScript | MDN
Along with having normal strings, template literals can also contain other parts called placeholders, which are embedded expressions delimited by a dollar sign and curly braces: ${expression}. The strings and placeholders get passed to a function — either a default function, or a function you supply. The default function (when you don't supply your own) just performs string interpolation to do substitution of the placeholders and then concatenate the parts into a single string.
Discussions

TIL JavaScript provides string interpolation with string template literals
Next thing to learn is probably tagged templates I have never really used them outside of React styled-components so you probably won't see them much but it's good to know they exist More on reddit.com
🌐 r/ProgrammerTIL
3
10
October 2, 2023
I made a new string interpolation library (typed-string-interpolation)
Can understand the efforts to push for lower bundle size but I glanced at your code and the variable names are single letters :| Is this by design? More on reddit.com
🌐 r/typescript
7
9
June 28, 2023
Problem with Variable Passing in String Interpolation Function Arguments

Nesting string interpolations in the arguments of an interpolation is not supported. Use regular concatenation instead, e.g.:

"result="++matches(sample, expression["toMatch"])
More on reddit.com
🌐 r/AutomateUser
1
1
February 17, 2022
Some comments about the new String Templates feature
The part I really like about your proposal is that it would make it easier to add support for string templates to existing APIs without having to make them more complicated. You could just add overloads that accept a string template to existing methods, instead of having add template processors as fields and having to tell users "okay, there's now a completely separate way of doing things". For example, given a hypothetical existing method HtmlEscaper.escape(TemplatedHtmlSnippet), I'd much rather be able to add HtmlEscaper.escape(StringTemplate) instead of having to resort to adding some static field HtmlEscaper.ESC. More on reddit.com
🌐 r/java
56
78
April 13, 2023
🌐
W3Schools
w3schools.com › js › js_string_templates.asp
JavaScript Template Strings
JS Examples JS HTML DOM JS HTML Input JS HTML Objects JS HTML Events JS Browser JS Editor JS Exercises JS Quiz JS Website JS Syllabus JS Study Plan JS Interview Prep JS Bootcamp JS Certificate JS Reference ... Template Strings allow variables in strings. Template strings provide an easy way to interpolate variables in strings. ... let header = "Template Strings"; let tags = ["template strings", "javascript", "es6"]; let html = `<h2>${header}</h2><ul>`; for (const x of tags) { html += `<li>${x}</li>`; } html += `</ul>`;
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › string-interpolation-in-javascript
String Interpolation in JavaScript - GeeksforGeeks
October 14, 2025 - You can use an array and the join() method to interpolate strings, though this is less common and more verbose. ... Hello, Alice! A custom function can be used to handle string interpolation, especially if the string structure is complex or repeated.
🌐
Medium
medium.com › @abhishekprasadkashyap › exploring-template-literals-javascripts-powerful-string-interpolation-5f62c1f04c0a
Exploring Template Literals: JavaScript’s Powerful String Interpolation | by Abhishek Prasad | Medium
October 3, 2024 - Use them to simplify string interpolation and multi-line strings instead of cluttering your code with + operators. 2. Avoid excessive logic inside templates: While you can embed any JavaScript expression inside a template literal, try to keep the logic simple.
🌐
Ben Ilegbodu
benmvp.com › blog › nested-string-interpolation-in-javascript
Nested string interpolation in JavaScript | Ben Ilegbodu
April 26, 2020 - It turns out that if you want to do the same thing with template literals and string interpolation, it becomes nested interpolation: const fullLocation = `${location}${venue ? ` (${venue})` : ''}` And it turns out that that Just Works™. I was afraid that the second backtick to start the nested interpolation would be parsed as the closing backtick from the beginning, but apparently once you're inside of a ${ } expression another set of backticks can be used!
🌐
Stanley Ulili
stanleyulili.com › javascript › template-literals-in-javascript-explained-like-your-twelve
Template Literals in JavaScript: Explained like You're Twelve
October 29, 2019 - String interpolation is a process where you can pass a valid JavaScript expression such as a variable into a template literal. The expression inside ${} is evaluated, and the result of the evaluation is embedded into the string as demonstrated in the example below:
Find elsewhere
🌐
Dmitri Pavlutin
dmitripavlutin.com › javascript-template-strings
How to Use Template Strings in JavaScript
March 21, 2023 - Template strings in JavaScript are surrounded by backticks `string` and perform string interpolation: `Hello ${who}!`
🌐
Jsremote
jsremote.jobs › tutorials › string_interpolation
What is string interpolation in JavaScript? | Web developer jobs
December 30, 2022 - While the example with cucumbers and tomatoes is fine, string interpolation in JavaScript can also work with multi-line strings.
🌐
Esdiscuss
esdiscuss.org › topic › how-to-delay-interpolation-of-template-strings
how to delay interpolation of template strings?
2014 à 09:27, Niloy Mondal <niloy.mondal84 at gmail.com> a écrit >> : >> >> I want to define a template string using backquotes in a different file >> and then have it interpolated with actual values in a different file. How >> can I do it? >> >> >> Just enclose it in a function: >> >> ```javascript >> function foo(a) { >> return `some template ${a}` >> } >> >> foo("bar") // will evaluate `some template ${"bar"}` >> ``` >> >> —Claude >> > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > > -------------- next part -------------- An HTML attachment was scrubbed...
🌐
MakeUseOf
makeuseof.com › home › programming › how do you format a string in javascript?
How Do You Format a String in JavaScript?
October 22, 2022 - Template literals let you use expressions in your JavaScript strings through a process called interpolation. With string interpolation you can embed expressions or variables in your strings using the ${expression} placeholder.
🌐
Go Make Things
gomakethings.com › template-literals-and-string-interpolation-in-vanilla-js
Template literals and string interpolation in vanilla JS | Go Make Things
May 4, 2021 - Any spaces or tabs inside the literal are included. In this case, the tab before the p element is included in the string as well.
🌐
Coffeescript-cookbook
coffeescript-cookbook.github.io › chapters › strings › interpolation
CoffeeScript Cookbook » String Interpolation
CoffeeScript interpolates strings in similar fashion to ruby. Most expressions are valid inside the #{...} interpolation syntax.
🌐
JavaScript in Plain English
javascript.plainenglish.io › chapter-62-unlocking-the-power-of-template-literals-string-interpolation-tagged-templates-in-9bf02322e7a5
Chapter 62:Unlocking the Power of Template Literals, String Interpolation & Tagged Templates in JavaScript 🎉 | by Aryan kumar | JavaScript in Plain English
October 18, 2024 - Welcome to JavaScript." ✅ · Backticks are used to define template literals (`). They support multiline strings without the need for special characters. String interpolation allows you to embed variables and expressions easily with ${}.
🌐
DEV Community
dev.to › mattlewandowski93 › template-literals-in-typescript-i36
Template Literals in TypeScript 📚✍️ - DEV Community
January 6, 2025 - Custom String Interpolation: You can define how values are interpolated into the string, allowing for complex transformations. DSL Creation: Tagged templates can be used to create domain-specific languages (DSLs) within JavaScript/TypeScript.
🌐
CoreUI
coreui.io › blog › what-is-javascript-printf-equivalent
JavaScript printf equivalent · CoreUI
June 22, 2024 - Here’s an example of formatting a number to two decimal places: const number = 1234.56789 console.log(`The formatted number is ${number.toFixed(2)}`) // The formatted number is 1234.57 · Although JavaScript has no direct printf equivalent, it provides several methods to achieve similar string formatting functionality.
🌐
Flexiple
flexiple.com › javascript › javascript-string-format
Javascript String Format - Flexiple
It merges two or more strings into one. var string1 = "Hello, "; var string2 = "world!"; var combinedString = string1 + string2; // "Hello, world!" b. Using the Template Literals (Backticks ` `): Template literals allow string interpolation ...
🌐
Futurestud.io
futurestud.io › tutorials › javascript-prevent-line-breaks-in-string-template-literals
JavaScript — Prevent Line Breaks in String Template Literals
April 25, 2024 - Template literates in JavaScript are delimited with backticks and allow you to create string interpolation and multi-line strings. A multi-line string with template literals is convenient because you can add words and line breaks without concatenating strings using a + across lines.