Determines if the specified value is a JavaScript Function.

function isFunction(fn) {
    var string = Object.prototype.toString.call(fn)
    return string === '[object Function]' ||
        (typeof fn === 'function' && string !== '[object RegExp]') ||
        (typeof window !== 'undefined' &&
            // IE8 and below
            (fn === window.setTimeout || fn === window.alert || fn === window.confirm || fn === window.prompt))
};