I am looking for a way to use a Template String from a variable in function.
This is a working example (not a variable)
let f = function () {
return `Hello ${this.name}!`
}
f.bind({
name: 'Stackoverflow-User'
})(); // Hello Stackoverflow-User!
This is the not working example (in a variable)
let s = `Hello ${this.name}!`;
let f = function () {
return s;
}
f.bind({
name: 'Stackoverflow-User'
})(); // Hello undefined!