Here we can see that to write a text in two lines, we have to write a newline character (\n) at the right place, we cannot simply write it in two lines as it appears in output so actually you cannot visualize the output until you run it. Or you have other options to break it into multiple strings and use + operator as above which may look little similar but doesn’t look clean at all.
As mentioned earlier that there are times when we have to put special characters in the string like colon, quote, double quote, backslash etc and it becomes more ugly and confusing. To get it working, we need to add special escape character (\) every time it appears in the text as
var message = 'Hello \'Brij\'\n, Did you use special chars in your new post \' Truthy and Falsy in JS\'?'
Or if you want to write some regex which would be full of special characters.
Let’s see the above example using the template literal.
Here we can see that we have message appearing in IDE and console exactly same and we didn’t have any escape character.
Template literal also allows to have expressions which could be a normal variable or normal mathematical expression as