Is there a way to store a string interpolation template into a variable in JavaScript and just call it as a function (or something like this)?
I would like to do something like this:
const myStr = `http://website.com/${0}/${1}`;
console.log(myStr('abc','def'));
// http://website.com/abc/def
2
Answers
You would want to write a function for it like the following:
Yes, just use an anonymous function, e.g.
if you want to use more than one argument just pass it like this