2 ms·
Even more nonsense possible since the tag function doesn't have to return a string, it can return a function, meaning you could chain these, e.g. function
by femto113 8y ago
Even more nonsense possible since the tag function doesn't have to return a string, it can return a function, meaning you could chain these, e.g.
function tag2(string, ...keys) {
console.log("tag2", string, ...keys);
return function tag1(string, ...keys) {
console.log("tag1", string, ...keys);
return "tag1-return-value"
}
}
console.log(tag2`input to tag2``input to tag1`);
yields
tag2 [ 'input to tag2' ]
tag1 [ 'input to tag1' ]
tag1-return-value