Say I have a variable str
var str = "123"
Now I could do console.log(`Hello ${str}`) and it will print Hello 123
Now I have another variable strnew
var strnew = 'Hello ${str}'
Note (based on answers/comments) - strnew is read from a file, so its always a string and cant be replaced with `
How do I console.log(...) to print Hello 123
Is it possible wihtout any kind of eval()
strand uses this template string inside._.templateinstead, or some other template engine. I don't see any option to generate template string from string.strnew.replace(/\$\{(.*?)\}/g,()=>window[RegExp.$1])if you are not using scopes