Overriding Object#toString should not happen in Prototype.
It's impossible to know what assumptions are made about the behavior
of this [fundamental, core] method by Firebug, jQuery, mooTools, or
the countless 3rd party libraries and applications out there.
The impact to Firebug that J.Higson points out is just one example.
There is also the performance impact to consider. The native
Object#toString is, I'm sure, blazingly fast. But replace that with
code that does the recursion and string construction necessary to
create a JSON description, and invoke it at the root of a large data
structure (or a data structure that has circular references?), and
things quickly grind to a halt. All of a sudden any code that comes
into contact with Prototype needs to be _much_ more careful about
where/when it invokes this method.
On Sep 8, 5:56 am, Joran <jorangr...@gmail.com> wrote:
> Dear Tobie
> Thank you for your reply. Could I suggest a few more questions?
> 1. Does EcmaScript 5 preclude one from modifying
> 2. Over-writing Object.prototype.toString does not at first glance
> appear to cause it to show up in for...in loops in Rhino, Safari or
> Firefox. This was the idea behind the suggestion, given the usual
> problems with extending Object.prototype. I have not tried other
> environments. Are there still other issues?
> 3. Object.toString returns "[object Object]". Surely returning more
> information than this would be no more misleading than the current
> implementation? Surely a toString method need not return a string
> which exactly describes the object but only a representation thereof?
> If point 1 above, would not a JSON representation be further along in
> the spirit of being more accurate and informative than "[object
> ..In the interest of being able to do: Console.log('Object: ' +
> object) instead of: Console.log('Object: ' + JSON.stringify(object)).
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to firstname.lastname@example.org
To unsubscribe from this group, send email to
For more options, visit this group at