📌  相关文章
📜  检查对象是否有方法 javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:52.257000             🧑  作者: Mango

代码示例2
if(typeof myObj.prop2 === 'function') {
    alert("It's a function");
} else if (typeof myObj.prop2 === 'undefined') {
    alert("It's undefined");
} else {
    alert("It's neither undefined nor a function. It's a " + typeof myObj.prop2);
}