Understanding tagged template literals in JavaScript
Introduction
You’ve probably come across template literals when writing JavaScript:
function sayHi(name) {
console.log(`Hi, ${name}!`);
}
sayHi("Zach"); // "Hi, Zach!"
Template literals are handy for their ability to interpolate values and crea...
zachsnoek.hashnode.dev6 min read
Victor Souza
Web Developer from π Canis Majoris.
Clearly explained! thanks for sharing it✨✨
I'll play with it more later :)
function bold(strings, ...args) { return [strings, args[1](args[0])]; } const html = bold`7^2 =${7}${function square(x) { return x*x; }}`; console.log(html.join(" "));