Why interpolate when we can use literals?

Hello!

I’m wondering if anyone could answer this question. Why do we interpolate strings around variables when we can use literals? An example would be;

let myWord = "DOWN"

console.log(`The chosen word is ${myWord}, just incase you are wondering`)
console.log("The chosen word is " + myWord + ", just incase you are wondering")

// Both of the above console.log commands output the following:
// The chosen word is DOWN, just incase you are wondering

When I interpolate, it feels like it’s a lot longer, closing the string, adding a connector, adding a variable, opening a new string and closing it again, when I could simply use backticks and achieve the same result?

This could be a very noobish question, however examples would be great of why we would interpolate instead of using template literals.

Template literals do not seem to be supported on IE and opera mini:

ES6 Template Literals (Template Strings) | Can I use... Support tables for HTML5, CSS3, etc

so if you need to support these browsers and you can’t transpile (with babel for example), then you can’t use template literals.

But I agree, the template literals feel better. So preferable use template literals when possible :slight_smile:

Great answer! Thanks for the link :+1: