Convert a string to a template string

Is it possible to create a template string as a usual string,

let a = "b:${b}";

and then convert it into a template string,

let b = 10;
console.log(a.template()); // b:10

without eval, new Function and other means of dynamic code generation?

21 Answers
21

Leave a Comment