Hi Kangax,
the match way is better for the undefined possibility, but have you tried to
*closurize* the method for performances?
__getClass = function(toString){return function(Object){
return toString.call(Object).match(/^\[object\s([^\]]+)\]$/)[1]
}}(Object.prototype.toString);
in my case only Chrome, WebKit, and IE8 have little improvements, so it's
probably a silly question :-)
Regards
On Fri, Oct 10, 2008 at 1:12 AM, kangax <[EMAIL PROTECTED]> wrote:
>
> On Oct 9, 2:33 pm, Nathan Hammond <[EMAIL PROTECTED]> wrote:
> > This showed up on Douglas Crockford's blog today:
> > Object.prototype.toString.apply(value) === '[object Array]'
> >
> > The trick appears to have been in circulation for about 6 months and
> > shows up in DWR as well as DC's book. DC credits Mark Miller for it.
> > Probably slower than the value.constructor == Array test we use
> > everywhere, but fixes the iframe-created object issue.
> >
> > 1. Should we adopt it for resiliency?
> > 2. @Michael Geary: Are you using this in your iframe sandbox code? It
> > sure would beat the heck out of duck typing.
> >
> > Just starting a discussion...
>
> Object.prototype.toString returns an internal [[Class]] property.
> I've been playing with this some time ago:
>
>
> http://github.com/kangax/protolicious/tree/master/experimental/__getClass.js
>
> > Nathan
>
> --
> kangax
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---