js判断是否为null 空 undefined

  • A、判断变量是否为'' null undefined
    if (null == modelType || 'undefined' == typeof(modelType) || '' == modelType) {
        return;
    }
    

  • B、null undefined变量转换''
    StringUtil.nullToString = function (str) {
        if (str === null || typeof str === 'undefined') {
            return '';
        } else {
            return `${str}`;
        }
    }
 
posted @ 2022-04-01 18:08  鸟不拉诗  阅读(231)  评论(0编辑  收藏  举报