The toString method returns a string representing a specified object.
The toString method is inherited by every object descended from Object
and returns a string representing a specified object. There are times when an object
needs to be represented as a string, and the toString method (which comes with every
object) is automatically called to do that. ToString returns the object type or the
constructor function that created it.
The toString method can, however, be overwritten in a custom object
by assigning a user-defined function in its place as follows:
NOTE:
Every core JavaScript object will over-ride the toString method to return an
appropriate value, and will only call it when it needs to convert an object to
a string.
Cat.prototype.toString = myToString
The toString method can be overwritten in a custom object by assigning a user-defined function in its place.
document.write(Sheeba)
[object Object]
document.write(Sheeba.toString)
function toString() { [native code] }