Template Literals in ES2015 (ES6)

Michie Riffic
MichieRiffic
Published in
1 min readAug 3, 2016

Template literal is the new thing.

It is identified with ` `.

let notes = `I am a template literal`;

Now, you can easily do a string concatenation in Javascript with the use of template literals.

String Concatenation

Strings being combined together to form one string

BEFORE:

To combine strings together, we use the + operator.

We can still use this style.
//Result in the consoleFull Name: John Snow

WITH TEMPLATE LITERALS:

We enclose our string with ` ` and variables are enclosed in ${ }.

To add in the variables in the string, enclose it using the ${ }.
//Result in the consoleFull Name: John Snow

Template literals make your life a bit easier and your code simpler and cleaner.

If this lesson has helped you in anyway, you can give it a ❤ or share it out. Thanks! :)

--

--