Calling a function without braces, but using template string in Node.js

Viewed 85

A function in JS can be called in the very strange way:

[1,2,3].join``
 -> "123"

Could somebody explain how it works "under the hood" or provide a link to some explanations?

3 Answers

It seems you are referring tagged templates which allow you to parse template literals with a function & first argument of a tag function is related to the expression. Here join is the tag function

console.log([1,2,3].join`,`)

Related