Hacker News new | past | comments | ask | show | jobs | submit login

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.



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




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: