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.
🌐
Flexiple
flexiple.com › javascript › javascript-string-interpolation
JavaScript String Interpolation - Flexiple
let name = "JavaScript"; let greeting = `Hello, ${name === "JavaScript" ? "developers" : "world"}!`; ... This example demonstrates how template literals and ternary operators can be used together to interpolate strings based on dynamic expressions, ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › string-interpolation-in-javascript
String Interpolation in JavaScript - GeeksforGeeks
October 14, 2025 - Template literals are the most modern and preferred method for string interpolation in JavaScript.
🌐
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>`;
🌐
W3docs
w3docs.com › javascript
How to Do String Interpolation in JavaScript
Javascript string interpolation and placeholder expression · const NUM = 8.3; console.log(`The number is ${NUM}`); ... It is important that any string that uses interpolation be wrapped in backticks (`), not “double quotes” or ‘single ...
🌐
TutorialsPoint
tutorialspoint.com › how-to-do-string-interpolation-in-javascript
How to do string interpolation in JavaScript?
In JavaScript by using string interpolation inputs can be inserted into the parts of the strings dynamically by using the placeholders. The traditional approach of inserting variables into the strings doesn't support the possibility of the inserting the inputs dynamically. This example demonstrates how to use a template literal to interpolate a string in JavaScript.
🌐
Medium
medium.com › @msajidsher › what-is-javascript-interpolation-596e010581b1
What is JavaScript interpolation? | by Dr. M. S. Sher | Medium
December 21, 2023 - What is JavaScript interpolation? Here’s a comprehensive explanation of interpolation in JavaScript: Interpolation is the process of embedding expressions or variables directly within strings …
Find elsewhere
🌐
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 - Instead of building HTML strings with concatenation, you can put variables directly into the string with interpolation. const name = "John" const htmlContent = ` <h1>Hello, ${name}!</h1> <p>Welcome to the site.</p> ` You can also insert variables directly into log messages without the need for concatenation. const user = "John" const action = "logged in" console.log(`User ${user} just ${action}`) // Outputs: User John just logged in · Template literals make it easier to construct URLs as well. const userId = 123 const apiUrl = `https://api.example.com/user/${userId}/details` console.log(apiUrl) // Outputs: https://api.example.com/user/123/details
🌐
SheCodes
shecodes.io › athena › 2991-using-variables-and-string-interpolation-in-js
[JavaScript] - Using Variables and String Interpolation in | SheCodes
Learn how to use variables with string interpolation in JavaScript to create strings with dynamic content. ... Im learning about the AJAX thing in the API thing and I am so confused. I'm really confused about how API exactly works and what exactly AJAX and Axios means. I'm really confused. What is this thing and where do I find it? can you explain this really easily and simply for me like explain as if I'm a child. Give easy real life examples ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Glossary › Interpolation
Interpolation - Glossary | MDN
The progression of interpolation also depends on easing functions in animations and color stops, and color and hue interpolation methods in gradients. In JavaScript, the term "interpolation" is used as a description of the substitution of strings in the template literals.
🌐
Ben Ilegbodu
benmvp.com › blog › nested-string-interpolation-in-javascript
Nested string interpolation in JavaScript | Ben Ilegbodu
A quick look at how nested string interpolation within template literals is possible with ES6
🌐
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
JavaScript template literals support string interpolation. For example, suppose you wanted to implement a function greet() that says "Hello" to the given name.
🌐
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 - Introduced in ECMAScript 6 (ES6), ... string interpolation, embedding expressions, multi-line strings, and more. In this article, we’ll dive deep into template literals and explore their various capabilities, providing examples and discussing how they can simplify your code. Whether you're a beginner or an experienced JavaScript developer, ...
🌐
Linux Hint
linuxhint.com › javascript-string-interpolation
JavaScript String Interpolation | Explained
Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
D3
d3js.org › d3-interpolate
d3-interpolate | D3 by Observable
This module provides a variety of interpolation methods for blending between two values. Values may be numbers, colors, strings, arrays, or even deeply-nested objects. For example: