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

String interpolation / template literals like JS? - language design - Rust Internals
At $dayjob I do quite a bit of JS, and although I often donโ€™t like it (the types! where are my types?!), there are couple of things I really enjoy. I was wondering if Rust could ever get something like https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals and ... More on internals.rust-lang.org
๐ŸŒ internals.rust-lang.org
4
December 22, 2018
javascript string interpolation / template literals / template strings - Misc Forum | Cycling '74
Using the js object I tried to employ string interpolation, but got the error: "js: midi2notename.js: Javascript SyntaxError: illegal ... More on cycling74.com
๐ŸŒ cycling74.com
November 20, 2023
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
๐ŸŒ
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}!`
๐ŸŒ
Mastering JS
masteringjs.io โ€บ tutorials โ€บ fundamentals โ€บ string-interpolation
JavaScript String Interpolation - Mastering JS
February 17, 2021 - JavaScript template literals support string interpolation. For example, suppose you wanted to implement a function greet() that says "Hello" to the given name.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ javascript-string-format-how-to-use-string-interpolation-in-js
JavaScript String Format โ€“ How to use String Interpolation in JS
September 8, 2020 - This allows us to check the value of a variable, and display different things depending on that value. ... const drinks = 4.99; const food = 6.65; const total = drinks + food; const result = `The total bill is ${total}. ${total > 10 ?
๐ŸŒ
DEV Community
dev.to โ€บ isaiah2k โ€บ string-interpolation-in-javascript-1gpb
String Interpolation in JavaScript. - DEV Community
October 15, 2024 - However, with the introduction of template literals in the JavaScript ES6(2015) update. We now have a cleaner way to insert variables into strings, called string interpolation. Template literals allow us to manipulate strings easier. They are enclosed in backticks (`) rather than (') or ("), and they support string interpolation by using the (${}) syntax to place variables, or function calls directly into a string. Hereโ€™s an example of how template literals simplify string interpolation.
๐ŸŒ
YoungWonks
youngwonks.com โ€บ blog โ€บ javascript-string-format
JavaScript String Formatting: A Comprehensive Guide
September 28, 2023 - The + operator, although commonly ... in JavaScript. For instance, const fullName = "John" + " " + "Smith" would yield the complete string "John Smith". Concatenation can become cumbersome for more complex strings or multi-line strings.
๐ŸŒ
Rust Internals
internals.rust-lang.org โ€บ language design
String interpolation / template literals like JS? - language design - Rust Internals
December 22, 2018 - At $dayjob I do quite a bit of JS, and although I often donโ€™t like it (the types! where are my types?!), there are couple of things I really enjoy. I was wondering if Rust could ever get something like https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals and ...
๐ŸŒ
Medium
medium.com โ€บ predict โ€บ switching-to-es6-part-2-string-interpolation-and-template-literals-2f1b0ee56740
Switching to ES6 (Part 2: String Interpolation and Template Literals) | by Sunny Beatteay | Predict | Medium
November 5, 2018 - First, you need to surround the string you want to interpolate with backticks, which you can find at the top left of your keyboard under the esc key (American keyboards). ... Second, you need to surround the JavaScript code that you want ...
๐ŸŒ
Cycling '74
cycling74.com โ€บ forums โ€บ javascript-string-interpolation-template-literals-template-strings
javascript string interpolation / template literals / template strings - Misc Forum | Cycling '74
November 20, 2023 - I'm aware of the workaround to concatenate the generated string with "\n", but was wondering why there's this deviation from the standard [Template literals (Template strings) - JavaScript | MDN] ... Copy patch and select New From Clipboard in Max. ... Can't see your code (clipboard copy in Max doesn't get the external files). However, your issue is likely that Javascript in Max is ES5 (2009), so it does not have many modern niceties.
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ dotnet โ€บ csharp โ€บ language-reference โ€บ tokens โ€บ interpolated
$ - string interpolation - format string output - C# reference | Microsoft Learn
January 14, 2026 - When you do that, any sequence of { or } characters shorter than the number of $ characters is embedded in the result string. To enclose any interpolation expression within that string, you need to use the same number of braces as the number of $ characters, as the following example shows:
๐ŸŒ
Bennadel
bennadel.com โ€บ blog โ€บ 2829-string-interpolation-using-util-format-and-util-inspect-in-node-js.htm
String Interpolation Using util.format() And util.inspect() In Node.js
April 21, 2020 - The .inspect() method provides a smarter "stringify" // method for complex objects that won't break with circular references (it will // inject "[Circular]" tokens in appropriate places in lieu of breaking). logError({ type: "InvalidArgument", message: "Friend.id does not match id.", detail: util.format( "Friend with id [%s] does not match given id [%s].", friend.id, id ), extendedInfo: util.format( "Arguments: %s", util.inspect( arguments ) ) }); } } // For this demo, we're just going to log the error details to the console. Notice that // the console.log() method also allows for string interpolation, the same way that the // util.format() method does.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ javascript-template-literals
JavaScript Template Literals - GeeksforGeeks
The function receives the static parts as an array and interpolated values separately. Returns a correctly formatted string without additional concatenation. Template literals build HTML strings dynamically. This example creates an h1 element.
Published ย  January 15, 2026
๐ŸŒ
Flexiple
flexiple.com โ€บ javascript โ€บ javascript-string-interpolation
JavaScript String Interpolation - Flexiple
This allows for dynamic string creation based on conditions in real-time, a significant advantage when handling complex logic. let name = "JavaScript"; let greeting = `Hello, ${name === "JavaScript" ? "developers" : "world"}!`; ... This example ...