These languages were developed for hypertext. Discord is hypertext. The question is why Rust or C++ or anything would be so suitable for developing chat rooms; it’s not even clear why JavaScript would necessarily be slower after being statically compiled.
Besides the obvious (it’s a web browser coevolution) it converts strings as needed, which is undeniably appropriate for the use case. Also indirect memory management and GC is appropriate for the use. It’s just more suited.
Yes, the first one is not required and shouldn’t be used, write your own leftpad then. The second is about as awful as getting NaN, which is to say not, and can be overridden in the prototype anyway if you want more casual logging.