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

Why doesn't console.log `foobar` work as imagined? It gives me an array.



Try adding interpolations to your example to make sense of this.

  console.log`foo${123}baz`
You get an array so that you later can interleaf the parts with the interpolations you get as additional arguments.


That’s actually the point, when you omit the parentheses the behavior changes, instead of interpolating the string and passing that to the function, the parts of the string get passed in instead.




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

Search: