js中判断是否为空

来源:互联网 发布:数据库crow s foot图 编辑:程序博客网 时间:2024/06/05 08:13

有三种方法:

<script type="text/javascript">

       var x;

       if(null == x){}

       if(typeof(x) == "undefined"){}

       if(!x){}

</script>

推荐第三种。


$.getSN = function(options){if (typeof(options) == "undefined" || options== null){return "";}else if(options.length > 50){return options.substr(0,50);}else{return options;}}


0 0
原创粉丝点击