string interpolation node js code example

Example 1: node js variable inside string

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

Example 2: string interpolation javascript

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

Example 3: string literal javascript

`string text`

`string text line 1
 string text line 2`

`string text ${expression} string text`

tag`string text ${expression} string text`

Example 4: ${ js

`string text`

`string text line 1
 string text line 2`

`string text ${expression} string text`

tag `string text ${expression} string text`