loading...
Cover image for # Template Literals in javascript

# Template Literals in javascript

shubhamggupta profile image Shubham Gupta Updated on ・1 min read

In a javascript, there was a different way of writing a string. the most common method is to use single and double quotes, for example

'String by a single quote'
         and 
"String by a double quote"

There was one more way through that you can write a string and that is backticks(`)

`String by a backtick`

Now why we should use this, the answer is With that syntax, you can dynamically add data into a string like this:

const city= "Pune";
const country = "India";
console.log(`My current city is ${city} and which is located in ${country});

final result:- My current city is Pune and which is located in India

There was an "old" way of concatenating strings:

"My current city is "+city+" and which is located in "+country

Discussion

markdown guide