23 boolean

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>
</title>


</head>

<body>

<script type="text/javascript">

/*
boolean 逻辑对象
*/
        //0  ->true 还是 false?   false
         var a = new Boolean(0);
         console.log(a);
         //1  ->true 还是 false?   true
         var b = new Boolean(1);
         console.log(b);
         //2 ->true 还是 false?   true
          var c = new Boolean(2);
          console.log(c);
          //空字符串表示 true 还是false?false  ctrl+d 复制本行到下一行
            //var d = new boolean(""); 错误 区分大小写
            /*
            boolean是基本数据类型
            Boolean是它的封装类,和其他类一样,有属性有方法,可以new,例如:
            Boolean flag = new Boolean("true"); // boolean 则不可以!
Boolean 是boolean 的实例化对象类,和Integer对应int一样
            
            
            */
            // ""空字符是 true 还是 false //false
              var  d = new Boolean("");
            console.log(d);
            //null?  //false
            var  e = new Boolean(null);
            console.log(e);
            //NaN?   //false
            var  t = new Boolean(NaN);
            console.log(t);
            // "false"?  //true  
            var b1= new Boolean("false");
            console.log(b1);
            
            //非 0 的数字 表示 true
            //非 空的 字符串 为true
            
            
            
        
  <!-- -->
</script>


</body>

</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值