Skip to content

Instantly share code, notes, and snippets.

@jdbruxelles
Created January 4, 2022 14:36
Show Gist options
  • Save jdbruxelles/86d54cc50b089096ea547c9e9387f3a1 to your computer and use it in GitHub Desktop.
Save jdbruxelles/86d54cc50b089096ea547c9e9387f3a1 to your computer and use it in GitHub Desktop.
A tagged template is a function call that uses a template literal to extracts arguments.
// A tagged template is a function call
// that uses a template literal to
// extracts arguments.
const sum = (msg, x, y) => {
return `${x} + ${y} = ${x + y}`;
};
document.write(sum`${45} ${15}`);
document.write("<br/>");
const div = (msg, x, y) => {
document.write(`${x} / ${y} = ${x / y}`);
};
div`${120} ${2}`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment