Created
August 18, 2017 15:48
-
-
Save sanketmeghani/3b405d1c4c2949807b844181f5f94bfe to your computer and use it in GitHub Desktop.
Template literals vs tagged template literals
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
const myFunction = () => { | |
return 'Returned from myFunction!'; | |
}; | |
const templateResult = `Function expression in template: ${() => myFunction()}`; | |
console.log(templateResult); //Outputs -> Function expression in template: () => myFunction() | |
const myTag = (literals, func) => { | |
return literals[0] + func(); | |
}; | |
const taggedResult = myTag `Function expression in template: ${() => myFunction()}`; | |
console.log(taggedResult); //Outputs -> Function expression in template: Returned from myFunction! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment