Template Literals

These are designed for making our strings easier to read and write.

They utilize the "back tick." This symbol -> `. It's just left of the "1" on your keyboard. We put our entire string inside two back ticks, and we use a dollar sign and curly brackets to insert JavaScript variables and expressions into.

We used to concatenate strings like so:

let name = "Jacob";
let age = 20;
console.log("hello, my name is " + name + " and I am " + age + " years old.");

but now we can use the following syntax:

console.log(`hello, my name is ${name} and I am ${age} years old.`);

This is easier to read and write, we can easily identify where the JavaScript variables are, and it takes up less room. All those quotes and "+"s in the old way are way to easy to mess up. Start using the ES6 way!

You can also insert JavaScript expressions into the curly brackets.

console.log(`hello, my name is ${name}. Next year, I will be ${age + 1} years old`);