tobie.langel at gmail.com
Wed Mar 11 04:20:16 PDT 2009
It is very useful to be able to specify the debugging representation
of an object distinctively from it's toJSON or toString representation.
We've been using that to great effect in Prototype, to help out, for
example, with the debugging representation of DOM Elements:
<div id="foo" class="foo bar">
is a much more useful representation than:
which you get in Safari/Firefox/Chrome or worse:
which you get in IE.
Indeed, Object.prototype.toSource seems closer to what I was
interested in. Unfortunately, it's
1) non standardized, and
2) apparently used internally by FF.
To be useful for debugging, such a method needs to provide a good
default value and be easily overridden for custom objects. I wouldn't
be too keen on overriding a method which the browser vendor claims to
On Mar 11, 2009, at 00:01 , Jason Orendorff wrote:
> On Sat, Mar 7, 2009 at 9:18 PM, Tobie Langel
> <tobie.langel at gmail.com> wrote:
>> The lack of a more developer-friendly representation of objects
>> than the one
>> obtained through their toString method (or by calling
>> Object.prototype.toString) made me long for an ES equivalent of
>> inspect instance method.
> You could use JSON.stringify(obj), which is on track to be
> standardized in ES3.1.
> (SpiderMonkey has the nonstandard uneval, as well as
> Object.prototype.toSource, which I think are a bit closer to what you
More information about the Es-discuss