if ( callbackfun != "undefined" ) { callbackfun(); } //发现判断不出来,最后查了下资料要用typeof //方法: if ( typeof(callbackfun) != "undefined" ) { callbackfun(); }
typeof 返回的是字符串,有六种可能:"number"、"string"、"boolean"、"object"、"function"、"undefined
if ( callbackfun != "undefined" ) { callbackfun(); } //发现判断不出来,最后查了下资料要用typeof //方法: if ( typeof(callbackfun) != "undefined" ) { callbackfun(); }
typeof 返回的是字符串,有六种可能:"number"、"string"、"boolean"、"object"、"function"、"undefined
转载于:https://www.cnblogs.com/yun007/archive/2013/01/30/2883091.html