Skip to content

Instantly share code, notes, and snippets.

@sanketmeghani
Created August 18, 2017 15:48
Show Gist options
  • Save sanketmeghani/3b405d1c4c2949807b844181f5f94bfe to your computer and use it in GitHub Desktop.
Save sanketmeghani/3b405d1c4c2949807b844181f5f94bfe to your computer and use it in GitHub Desktop.
Template literals vs tagged template literals
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