hsmWorld

js判断字段是否为空 isNull

//在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

发表于 2018-12-08 16:08    阅读(2627)  评论(0编辑  收藏  举报
 

分类:

技术点:

相关文章:

  • 2021-12-10
  • 2021-11-02
  • 2022-12-23
  • 2021-12-10
  • 2022-01-07
  • 2021-06-11
猜你喜欢
  • 2022-02-10
  • 2021-12-10
  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案