3 ms·
Worth noting also that there's nothing magical about the backtick being adjacent to the function, you can have whitespace inbetween, e.g func `123 ${abc
by femto113 8y ago
Worth noting also that there's nothing magical about the backtick being adjacent to the function, you can have whitespace inbetween, e.g
func `123 ${abc}`
or even
func
`123 ${abc}`
Coupled with the vagueness around ; I expect this will make for some awesomely obfuscated JavaScript in the coming years.
- femto113 8y agoEven 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