Object.prototype.inspect ?

Brendan Eich brendan at mozilla.com
Thu Mar 12 14:04:19 PDT 2009

On Mar 12, 2009, at 1:54 PM, P T Withington wrote:

> But, I would very much like to see a standard way to discover an  
> Object's constructor, and a way to enumerate _all_ the properties of  
> an object.  I know there is a tension between security and  
> introspection.  I don't know if this is something that can be  
> handled by the presumably already-overloaded strict mode.

ES3.1 has Object.getOwnPropertyNames and  
Object.getOwnPropertyDescriptor, so you can go to town with those.

Identifying the constructor is harder. Having to slice a substring out  
of Object.prototype.toString.call(obj) is disgusting, but it kind of  
works. Not sure about all the various non-standard class names  
formatted that way (IE calls DOM classes "Object"?!).


More information about the Es-discuss mailing list