0

javascript 判断对象是否有某方法

blue created at7 years ago view count: 2637
report
回复
0

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); }

6 years ago 回复