1var animal = "cow";
2var str=`The ${animal} jumped over the moon`; // string interpolation
1//Regular string
2var rgb = "rgb(" + r + "," + g + "," + b + ")";
3//Template literal
4var rgb = `rgb(${r}, ${g}, ${b})`;
1`string text`
2
3`string text line 1
4 string text line 2`
5
6`string text ${expression} string text`
7
8tag`string text ${expression} string text`
1// TEMPLATE LITERALS example
2console.log(`Hi, I'm ${p.name}! Call me "${p.nn}".`);
1//Must use backticks, `, in order to work.
2
3let a = 5;
4let b = 10;
5console.log(`Fifteen is ${a + b} and
6not ${2 * a + b}.`);
7
8//Output:
9//Fifteen is 15 and not 20.
1`string text`
2
3`string text line 1
4 string text line 2`
5
6`string text ${expression} string text`
7
8tag `string text ${expression} string text`
9