js判断字段是否为空 isNull()问题 ( js没有isNull函数,这个函数是自己写的)

您所在的位置:网站首页 数据库中isnull是什么意思啊 js判断字段是否为空 isNull()问题 ( js没有isNull函数,这个函数是自己写的)

js判断字段是否为空 isNull()问题 ( js没有isNull函数,这个函数是自己写的)

2024-02-25 12:32| 来源: 网络整理| 查看: 265

//在js中if条件为null、undefined、0、NaN、""、false,表达式时,统统被解释为false,此外均为true 。 //为空判断函数 function isNull(str) {  return !str && str!==0 && typeof str!=="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

 

===================

export function isNull(str) { if (str === null || str === undefined || str.length === 0) { return true } return false }

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3