closed → reopened
Actually, in this case it's not the modification of the prototype, which is pretty common and does work. The problem is that the method returns
this, so it is converting the primitive Strings into String objects. If you return
this.toString() it works fine.
The documentation is pretty clear that we want strings, not string *objects* which are a totally different thing. String objects may work in some APIs but it's largely by luck and not design.