1//Regular string
2var rgb = "rgb(" + r + "," + g + "," + b + ")";
3//Template literal
4var rgb = `rgb(${r}, ${g}, ${b})`;
1var str = "foo";
2var myString = `Insert variables inside strings like this: ${str}`;
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//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