0

javascript 判断对象是否有某方法

blue created at5 years ago view count: 2428
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); }

5 years ago 回复

Recent search keywords