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
转载于:https://www.cnblogs.com/hsmWorld/p/10088004.html
最后
以上就是老迟到棉花糖最近收集整理的关于js判断字段是否为空 isNulljs判断字段是否为空 isNull的全部内容,更多相关js判断字段是否为空内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复