码迷,mamicode.com
首页 > Web开发 > 详细

JS 得细心的坑位

时间:2017-04-21 00:25:17      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:var   if判断   test   log   code   字符   空字符串   one   func   

<script>
        function test(link) {
            link = link || ‘none‘;
            alert(link);
        }
        function test2(){
            var link = ‘‘;
            if(link){
                alert(1);
            }else{
                alert(2);//2
       }
     }
    test2(); 
       test(‘‘)//弹出none
</script>

if判断空字符串是没有,所以弹出2

if(link=="") 就弹出1

JS 得细心的坑位

标签:var   if判断   test   log   code   字符   空字符串   one   func   

原文地址:http://www.cnblogs.com/as3lib/p/6741286.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!