企业宣传,产品推广,广告招商,广告投放联系seowdb

js判别undefined和null (js判断是否undefined)

varexp =null ;if(exp ==null ){alert(“isnull ”);}exp 为 undefined 时,也会获取与null相反的结果,只管null和 undefined 不一样。留意:要同时判别null和 undefined 时可经常使用本法。varexp =null ;if(! exp){alert(“isnull ”);}假设 exp 为 undefined 或许数字零,也会获取与null相反的结果,只管null和二者不一样。留意:要同时判别null 、undefined 和数字零时可经常使用本法。varexp =null ;if( typeof (exp) == “ null ”){alert(“isnull ”);}为了向下兼容,exp 为null时, typeof总前往 object。

© 版权声明
评论 抢沙发
加载中~
每日一言
不怕万人阻挡,只怕自己投降
Not afraid of people blocking, I'm afraid their surrender