Overview
Javascript’s new version (EcmaScript 6) has some amazing new features. The one discussed in this post is template strings. Template strings are similar to string interpolation in swift and python. It uses backticks instead of double or single quotes. More information can be found here.
Examples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var first = "Jake"
, last = "Daisy";
var name1 = "My name is " + first + " " + last;
var name2 = `My name is ${first} ${second}`;
// "My name is Jake Daisy"
var test1 = `Hello`;
// '"Hello"'
var test2 = 5
, test3 = 6;
`test2 + test3 = ${ test2 + test3 }`
// "test2 + test3 = 11"