How to interpolate variables in strings in JavaScript, without concatenation?

I know in PHP we can do something like this: $hello = “foo”; $my_string = “I pity the $hello”; Output: “I pity the foo” I was wondering if this same thing is possible in JavaScript as well. Using variables inside strings without using concatenation — it looks more concise and elegant to write. 16 s 16 You … Read more

How can I do string interpolation in JavaScript?

Consider this code: var age = 3; console.log(“I’m ” + age + ” years old!”); Are there any other ways to insert the value of a variable in to a string, apart from string concatenation? 2Best Answer 21 Since ES6, you can use template literals: const age = 3 console.log(`I’m ${age} years old!`) P.S. Note … Read more