const age = 3 console.log(`I'm ${age} years old!`)
//Regular string var rgb = "rgb(" + r + "," + g + "," + b + ")"; //Template literal var rgb = `rgb(${r}, ${g}, ${b})`;
var animal = "cow"; var str=`The ${animal} jumped over the moon`; // string interpolation
const number = 42; const message = `The number is ${number}`; message; // => 'The number is 42'
// TEMPLATE LITERALS example console.log(`Hi, I'm ${p.name}! Call me "${p.nn}".`);
`string text` `string text line 1 string text line 2` `string text ${expression} string text` tag`string text ${expression} string text`
let value = dummy`Ik ben ${name} en ik ben ${age} jaar`; function dummy() { let str = ""; strings.forEach((string, i) => { str += string + values[i]; }); return str; }
`string text` `string text line 1 string text line 2` `string text ${expression} string text` tag `string text ${expression} string text`