6 ms·
JS Template strings (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/template_strings https://developer.mozilla.org/en-US/docs/Web/JavaScript/
by monk_e_boy 12y ago
JS Template strings (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/template_strings https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...):
Template strings are enclosed by the back-tick, `string text ${expression} string text`
var a = 5;
var b = 10;
console.log(`Fifteen is ${a + b} and not ${2 * a + b}.`);
// "Fifteen is 15 and not 20."
You can also 'tag' a template string:
tag`Hello ${ a + b } world ${ a * b}`;
where the 'tag' is a preprocessor function.