Javascript判斷function是否定義

jQuery可以用 isFunction() 來進行判斷

如果僅使用Javascript可以使用以下的方法

function isFunction(fn){
    return typeof fn === 'function'
}

function isDefined(foo){
    return typeof(foo) !== 'undefined'
}
原文地址:https://www.cnblogs.com/sipher/p/11634156.html