Created
January 4, 2022 14:36
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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