var o = {valueOf:function(){return "[function]"},toString:null};

alert(isFunction(o)); // true in IE

DBJ what is the problem, really? I wrote two options and both do what you
are trying to di with hundreds of tests ... is it that difficult?

var isFunction = (function(toString){
    var s = toString.call(toString),
        u = typeof u;
    return typeof this.alert === "object" ?
        function(f){
            return s === toString.call(f) || (!!f && typeof f.toString == u
&& /^\s*\bfunction\b/.test(f));
        }:
        function(){
            return s === toString.call(f);
        }
    ;
})(Object.prototype.toString);

Regards



On Wed, Aug 5, 2009 at 8:57 AM, DBJDBJ <dbj...@gmail.com> wrote:

>
> V.5 ?!
> Here is the (hopefully) proper verion :
>
> // GPL (c) 2009 by dbj.org
>         function isFunction (x) {
>                       switch(typeof x) {
>                       case "function" : return true ;
>                       case "object"   :
>                            if ( "function" !== typeof x.toString )
>                                return (x + "").match(/function/) !==
> null ;
>                            else
>                                return Object.prototype.toString.call
> (x) === "[object Function]" ;
>                        break ;
>                       default    : return false ;
>        }
> }
>
> // this was breaking the previous version
> window.test = {
>  toString: function() { return '[function]'; }
> };
>
> isFunction( test )
> /*
> false
> */
> isFunction( isFunction )
> /*
> true
> */
> isFunction( confirm )
> /*
> true
> */
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to