isFunction() that works in IE too

isFunction() that works in IE too


I think we all know that In IE, typeof window.alert , returns “object”
Here is my portable isFunction() , IMHO it might be ine of the
simplest solutions that I have seen?
// GPL (c) 2009 by DBJ.ORG
var isFunction = typeof (top.alert) == "object" ?
function(x) {
return (x + "").match(/function/) !== null ;
}
:
function (x) {
return x instanceof Function;
}
// test
isFunction( window.alert )
// returns true, in all browsers
Enjoy …
--DBJ