When converting objects into strings that have a custom toString method, I've noticed the lib calls valueOf instead. I don't know if this is intentional, but it really is confusing if you aren't expecting this behavior.
console.log(stripIndents`
${obj} is cool!
`);
Assuming obj has a valueOf that returns "1" and a toString that returns "2", the valueOf gets called, which in normal template literals is not the case.
When converting objects into strings that have a custom
toString
method, I've noticed the lib callsvalueOf
instead. I don't know if this is intentional, but it really is confusing if you aren't expecting this behavior.Assuming obj has a
valueOf
that returns "1" and atoString
that returns "2", thevalueOf
gets called, which in normal template literals is not the case.