1var name = 'World';
2var cname = 'javaTpoint';
3console.log(`Hello, ${name}!
4Welcome to ${cname}`);
5
1//Regular string
2var rgb = "rgb(" + r + "," + g + "," + b + ")";
3//Template literal
4var rgb = `rgb(${r}, ${g}, ${b})`;
1// string literals ('') and ("").
2const greeting1 = "Hello";
3console.log(greeting1 + " World!");
4
5// template string (``).
6const greeting2 = "Hey";
7console.log(`${greeting2} World!`);
8
9// the cool thing about string literals is that you can write expressions inside them.
10const num1 = 10;
11const num2 = 34;
12
13// ${num1 + num2} or any other calculation work well with template literals
14console.log(`the result of ${num1} + ${num2} = ${num1 + num2}.`);
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`
1const classes = `header ${ isLargeScreen() ? '' :
2 `icon-${item.isCollapsed ? 'expander' : 'collapser'}` }`;