js字符变量判空

测试代码:测试

        var params1 = '';
        var params2 = null;
        var params3;
        alert(typeof params1); // string
        alert(typeof params2); // object
        alert(typeof params3); // undefined
        alert(typeof params4); // undefinedstring

结论:变量

根据上述代码可得出严格意义上的js字符变量判空条件:object

  if (typeof params != 'undefined' && params != null && params != '');字符

相关文章
相关标签/搜索