Suppose a variable x
has numeric value 0.5
.
"cake" + x
will return "cake0.5"
without complaining. What are the merits of explicitly writing "cake" + x.toString()
in the code in Javascript? I expect it's considered better code-style to be explicit. But I'm not very experienced with JS. Is it more performant to write the explicit conversion, rather than allow the compiler to figure it out?
When would there be a reason to omit the explicit conversion?