js 判断数据是否为空
发布日期:2021-06-30 21:43:08 浏览次数:2 分类:技术文章

本文共 825 字,大约阅读时间需要 2 分钟。

//    var a = "";//    var a = " ";//    var a = null;//    var a = undefined;//    var a = [];//    var a = {};//    var a = NaN;        if(a === undefined) { // 只能用 === 运算来测试某个值是否是未定义的        console.log("为undefined");    }        if(a == null) { // 等同于 a === undefined || a === null        console.log("为null");    }        // String        if(a == "" || a == null || a == undefined){ // "",null,undefined        console.log("为空");    }    if(!a){ // "",null,undefined,NaN        console.log("为空");     }    if(!$.trim(a)){ // "",null,undefined        console.log("为空");    }    // Array    if(a.length == 0){ // "",[]        console.log("为空");    }    if(!a.length){ // "",[]        console.log("为空");    }    // Object {}    if($.isEmptyObject(a)){ // 普通对象使用 for...in 判断,有 key 即为 false        console.log("为空");    }

原文:

转载地址:https://local.blog.csdn.net/article/details/84998110 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Flutter安装、配置、及demo运行(Mac)
下一篇:IntelliJ IDEA For Mac 快捷键

发表评论

最新留言

哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年04月13日 19时56分00秒