|
|
|
|
|
by mhink
1201 days ago
|
|
The difference is on the tag side. "Tag functions" receive the string segments separately from the interpolated values, so like: function exampleTag(stringSegment, ...values) {
console.log(stringSegment);
console.log(values);
}
const myNumber = 123;
exampleTag`foo ${myNumber} bar ${myNumber}`;
// Prints:
// ['foo', 'bar', '']
// [123, 123]
This gives the tag function a way to access the interpolated values themselves, before they get coerced to a String. You're correct, though, that it really doesn't make much of a difference for a dedent function. |
|
A stale GitHub issue on the dmnd/dedent repo has a real-world example where this matters and led to a subtle bug: https://github.com/dmnd/dedent/issues/22