Function name is in the latest ES6 draft.
On Fri Feb 07 2014 at 11:15:31 PM, Timothy Quinn <tim.c.quinn at gmail.com>
wrote:
> Digging into ECMA-262, I cannot find this noted but it appears to be
> implemented in V8 and SpiderMonkey.
>
> Mozilla states this as non-standard<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name>so I am guessing that its not documented in ECMA-262.
>
> Is this defined in the specification or did I miss it? If not, +1 on its
> standardization into the specification.
>
> - Tim
>
>
> On Fri, Feb 7, 2014 at 10:52 PM, Timothy Quinn <tim.c.quinn at gmail.com>wrote:
>
> LOL. I did not realize that was implemented already :)
>
> Thanks,
> - Tim
>
>
> On Fri, Feb 7, 2014 at 10:28 PM, Domenic Denicola <
> domenic at domenicdenicola.com> wrote:
>
> o.constructor.name seems good?
> ------------------------------
> From: Timothy Quinn <tim.c.quinn at gmail.com>
> Sent: 2/7/2014 22:26
> To: es-discuss at mozilla.org
> Subject: Efficient determination of implemented class name
>
> An area of challenge in JavaScript is the ability to detect a
> JavaScript objects implemented class name. I have done this in the past
> with some success by parsing the objects constructor but I know that this
> depends on the Object constructor being named and is not very efficient as
> it requires the processing of a large string.
>
> Is it possible to include into the ECMA Specification a method of Object
> that returns the constructor function name which can be subsequently be
> used as an efficient class name detection mechanism? Maybe
> <Object>.getFunctionName().
>
> My current current slow but steady method for detecting classes is as
> follows:
>
> function objClassName(o){
> if(o===undefined){return "(undefined)" }
> if(o===null){return "(null)" }
> var a=/function\s+(.+)\s*\(.*\)\s*\{/.exec(o.constructor)
> return (a && a[1] ? a[1] : "(unknown)")
> };
>
> Thanks!
> Tim
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140208/c49e8ace/attachment.html>
domenic at domenicdenicola.com (2014-02-10T22:36:21.633Z)