WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
30962
Use Object#toString to render object name in console and object tree
https://bugs.webkit.org/show_bug.cgi?id=30962
Summary
Use Object#toString to render object name in console and object tree
Dan Dean
Reported
2009-10-30 13:43:37 PDT
I find it very useful that Firebug uses the toString method of an object to render the identifier of an object in all JS object inspections. I would love to see this bit of functionality in the WebKit Web Inspector. Example: console.log({ toString: function() { return "[object MyAwesomeObject]"; } }); Firebug Console: --> MyAwesomeObject WebKit Console: --> Object
Attachments
Image of usefulness of toString in the ExtJS framework
(73 bytes, text/plain)
2010-04-15 18:55 PDT
,
Steven Roussey
no flags
Details
Image of usefulness of toString in the ExtJS framework
(35.91 KB, image/jpeg)
2010-04-15 18:57 PDT
,
Steven Roussey
no flags
Details
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Timothy Hatcher
Comment 1
2009-10-30 21:04:04 PDT
We could do this. Right now we avoid it since some default toString methods are less than desirable (string, array to name a couple.)
Dan Dean
Comment 2
2009-11-03 09:47:09 PST
(In reply to
comment #1
)
> We could do this. Right now we avoid it since some default toString methods are > less than desirable (string, array to name a couple.)
I agree with you on the native types. I think the current behavior should remain for String, Array, Number, Boolean and RegExp objects. Probably a couple others too, like HTMLElement... This functionality is very useful for custom objects, though I understand how the implementation could be rather complex.
Timothy Hatcher
Comment 3
2009-12-04 13:03:03 PST
I agree we should do this for custom object.
Timothy Hatcher
Comment 4
2009-12-04 13:03:38 PST
<
rdar://problem/7444878
>
Steven Roussey
Comment 5
2010-04-15 18:55:06 PDT
Created
attachment 53502
[details]
Image of usefulness of toString in the ExtJS framework Reference:
http://www.extjs.com/forum/showthread.php?97007-ExtJS-debugging-help-in-Firebug
Steven Roussey
Comment 6
2010-04-15 18:57:07 PDT
Created
attachment 53503
[details]
Image of usefulness of toString in the ExtJS framework Reference:
http://www.extjs.com/forum/showthread.php?97007-ExtJS-debugging-help-in-Firebug
Joseph Pecoraro
Comment 7
2015-02-18 01:37:09 PST
So we've made some improvements here. We don't parse toString's, but we do deeper analysis of object's constructor properties / native type information. We recently improved our handling here: js> function Foo() {}; new Foo // Always handled this Foo {} js> Bar = function() {}; new Bar // Just made this work Bar {} As for letting scripts provide a name. If we end up with "Object" given the analysis above, then we fallback to "obj.constructor.name" if it is available. A rather crude example: js> console.log({constructor:{name:"test"}}) test {} -- That said, neither Firebug nor FireFox's developer tools seem to do this anymore. I think they have likely moved to constructor.name or better inference as well.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug