Thursday, 9 June 2016

javascript - Template Literal Tag Function with variable?

Is it possible for a variable that has been assigned the value of a template literal to be passed to a function, and then that function calls it with a function?



Example:



function strLiteralProcessor(str){
console.log(str);
return //what goes here? I want to call the tag function myTagFunc with str, but myTagFuncstr is obviously wrong.
};

var name = prompt("What's your name?");

strLiteralProcessor(`Hi, ${name}!`);


Do I do something like myTagFunc(str) or am I missing something?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...