Why are parentheses not needed in the following ES2015 code using a template literal?
['a', 'b'].join`|` // a|b
Why are parentheses not needed in the following ES2015 code using a template literal?
['a', 'b'].join`|` // a|b
Pretty sure this is a "tagged template string". From the ES6 wiki:
Example: If a template string is preceded by an expression it is considered a tagged template string. The expression before the template string is called with the parsed template string.
function tag(strings, ...values) {
assert(strings[0] === 'a');
assert(strings[1] === 'b');
assert(values[0] === 0);
return 'whatever';
}
tag `a${ 42 }b` // "whatever"