With Node.js v4 , you can use ES6's Template strings

var my_name = 'John';
var s = `hello ${my_name}, how are you doing`;
console.log(s); // prints hello John, how are you doing

You need to wrap string within ` (backtick) instead of ' (apostrophe)

Answer from Sridhar on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Scripting › Strings
Handling text — strings in JavaScript - Learn web development | MDN
Template literals mostly behave the same as normal strings, but they have some special properties: You can embed JavaScript in them. You can declare template literals over multiple lines. Inside a template literal, you can wrap JavaScript variables or expressions inside ${ }, and the result will be included in the string:
🌐
Scaler
scaler.com › home › topics › what is javascript string format?
What is JavaScript string format? - Scaler Topics
June 27, 2024 - This is one of the most convenient ... this method, the strings are simply wrapped within the backticks ( `` ) and the variables to be inserted are wrapped within curly braces ( {} ) preceded by a dollar sign ($)....
Discussions

How do I put variables inside javascript strings? - Stack Overflow
If you are stuck with sprintf formatting you can use util.format('hello %s, how are you doing', my_name) which still works in v14.15.4! see the docs nodejs.org/docs/latest/api/… ... You can use find-and-replace library for variables, like custom-string-formatter. More on stackoverflow.com
🌐 stackoverflow.com
How to insert variables in JavaScript strings? - Stack Overflow
Pretty sure you accidentally transposed the variables. The way you have it written, I would expect it to set str to be "My username is Github on tjcafferkey" 2017-07-19T16:10:16.607Z+00:00 ... Great spot. Got them the wrong way round on my example. 2017-07-19T16:20:04.097Z+00:00 ... That's fine in JavaScript. There is no good built-in equivalent of an sprintf or String.format... More on stackoverflow.com
🌐 stackoverflow.com
How do I use String:format in Javascript rules
Dear all, in OH2 I’ve used String::format in DSL-Rules: var Number temp = ((HausAussentemperatur_ActualTemperature.state as Number).floatValue) var lage = (Localweatherandforecast_Wetterlage.state.toString) var String Ausgabe = String::format("%s bei %.1f°C", lage, temp) In OH3 Javascript ... More on community.openhab.org
🌐 community.openhab.org
1
1
June 23, 2021
Formatting of variable insertion causing issues with custom JS
I’m using a regex extraction to get a URL from a string, but when I try to insert a variable from WeWeb as a variable into my JS code, the formatting seems to be messing it up. Has anyone else run into this? Here is the code, an example variable would be any string in the format “location: ... More on community.weweb.io
🌐 community.weweb.io
1
0
June 26, 2023
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-string-formatting
JavaScript String Formatting - GeeksforGeeks
August 5, 2025 - Template literals in JavaScript allow you to embed not just simple variables but also expressions inside ${} placeholders. This makes string formatting more flexible and powerful, as you can directly include calculations or function calls within the string.
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › javascript fundamentals
Variables
2 weeks ago - There are two limitations on variable names in JavaScript: The name must contain only letters, digits, or the symbols $ and _. The first character must not be a digit. ... When the name contains multiple words, camelCase is commonly used. That is: words go one after another, with each word except the first starting with a capital letter: myVeryLongName.
🌐
Flexiple
flexiple.com › javascript › string-format
JavaScript String Format – Formatting Strings in JS - Flexiple
June 6, 2024 - Using String interpolation in JavaScript simplifies the process of formatting strings. JavaScript developers often use template literals, a feature introduced in ES6, for string interpolation. Template literals are enclosed by backticks ( ) instead of the traditional single or double quotes. This feature allows variables and expressions to be embedded directly within a string, improving readability and ease of use.
🌐
SheCodes
shecodes.io › athena › 8931-creating-a-string-with-variables-in-javascript
[JavaScript] - Creating a String With Variables in | SheCodes
Learn how to add a variable to a string using either string concatenation or string interpolation with template literals for a more modern approach. ... if I have a variable outside a function, do I need to redefine that variable inside the function? similarly, can use the same name for a variable if one is in a function? variable function scope outer variable local variable let const ... How do I make a javascript event where you click on a thumbnail image and it pops up with a full sized image?
Find elsewhere
🌐
Telerik
telerik.com › blogs › string-formatting-python
String Formatting in Python
January 6, 2023 - In this two-part article series, we will look at string formatting in Python and compare it with template literals in JavaScript. String formatting refers to the ability to substitute parts of a string with values contained in variables or expressions.
🌐
W3Schools
w3schools.com › js › js_variables.asp
JavaScript Variables
Start the statement with let or constand separate the variables by comma: let person = "John Doe", carName = "Volvo", price = 200; Try it Yourself » ... In JavaScript, the equal sign (=) is an assignment operator, not an equal to operator.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Template_literals
Template literals (Template strings) - JavaScript | MDN
Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded expressions, and special constructs called tagged templates.
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Grammar_and_types
Grammar and types - JavaScript | MDN
So, for example, you could define a variable as follows: ... Because JavaScript is dynamically typed, this assignment does not cause an error message. In expressions involving numeric and string values with the + operator, JavaScript converts numeric values to strings.
🌐
W3Schools
w3schools.com › js › js_string_templates.asp
JavaScript Template 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 += ...
🌐
TypeScript
typescriptlang.org › docs › handbook › typescript-in-5-minutes.html
TypeScript: Documentation - TypeScript for JavaScript Programmers
For example, to create an object with an inferred type which includes name: string and id: number, you can write: ... You can then declare that a JavaScript object conforms to the shape of your new interface by using syntax like : TypeName after a variable declaration:
🌐
Medium
medium.com › @onlinemsr › javascript-string-format-the-best-3-ways-to-do-it-c6a12b4b94ed
JavaScript String Format: The Best 3 Ways To Do It | by Raja MSR | Medium
January 14, 2025 - Using the plus sign (+) to format the simple string is the traditional approach. With this method, you have to insert a JavaScript variable in a string separated by the + sign.
🌐
Guru99
guru99.com › home › javascript › javascript string format: methods with examples
JavaScript String Format: Methods with EXAMPLES
July 28, 2025 - Concatenation is a simple method utilized for formatting strings in JavaScript. This approach involves combining string variables or multiple strings together using the concatenation operator “+”. You can also use this technique for simple string concatenation tasks.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-create-a-string-with-variables-in-javascript
How to Create a String with Variables in JavaScript? - GeeksforGeeks
November 12, 2024 - Template literals (backticks and ${} syntax) are recommended for creating strings with variables because they are more readable, support multi-line strings, and make it easy to include expressions and complex formatting.