Object.prototype.inspect ?

Brendan Eich brendan at mozilla.com
Thu Mar 12 16:27:04 PDT 2009

On Mar 12, 2009, at 2:25 PM, Tobie Langel wrote:
> Could we possibly imagine having a non-[[Writable]] and non- 
> [[Configurable]] 'name' property of built-in constructors whose  
> value would be [[Class]] ?

So a string-valued property, e.g. f.constructor.name === "Function"  
for function f(){}, d.constructor.name === "Date" for (d = new Date),  

Works for me, already implemented in SpiderMonkey. Note constructor  
being writable and configurable as I mentioned in reply to Tucker just  
now. If we want to avoid that hazard, we would need a separate,  
optionally locked-down method, say Object.getClassName(o).


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20090312/8d9442ac/attachment.html>

More information about the Es-discuss mailing list