码迷,mamicode.com
首页 > Web开发 > 详细

js判断字段是否为空 isNull

时间:2018-12-08 17:01:53      阅读:5735      评论:0      收藏:0      [点我收藏+]

标签:alert   key   判断   表达   nbsp   return   cal   keyword   null   

//在js中if条件为null/undefined/0/NaN/""表达式时,统统被解释为false,此外均为true .
//为空判断函数
function isNull(arg1)
{
 return !arg1 && arg1!==0 && typeof arg1!=="boolean"?true:false;
}


//alert(isNull(null));    //true
//alert(isNull(‘‘));      //true
//alert(isNull());       //true
//var aa={};          
//alert(isNull(aa.a));   //true
//alert(isNull(0));        //false
//alert(isNull(‘0‘));    //false
//alert(isNull(true));   //false
//alert(isNull("undefined"));  //false
//alert(isNull(undefined));     //true
//alert(isNull([]));       //false
//alert(isNull({}));       //false

 

来自:http://blog.sina.com.cn/s/blog_68ead6830101cx3u.html

js判断字段是否为空 isNull

标签:alert   key   判断   表达   nbsp   return   cal   keyword   null   

原文地址:https://www.cnblogs.com/hsmWorld/p/10088004.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
分享档案
周排行
mamicode.com排行更多图片
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!