3.5.1 布尔值
// 布尔型也被称为逻辑值类型或者真假值类型。
// 布尔型只能够取真(true)和假(false)两种数值。
// 除此以外,其他的值都不被支持。
var hzh1 = true;
console.log("它们是true还是false?");
console.log("hzh1?" + hzh1);
console.log("(!hzh1)?" + (!hzh1)); // true的否定为false
console.log("(!!hzh1)?" + (!!hzh1)); // 否定的否定为肯定
console.log("**************************************************");
// 对布尔值进行 typeof 运算的话,得到的结果为 "Boolean"。
console.log("它们是什么数据类型?");
console.log("true?" + true);
console.log("false?" + false);
console.log("hzh1?" + hzh1);
console.log("(!hzh1)?" + (!hzh1)); // true的否定为false
console.log("(!!hzh1)?" + (!!hzh1)); // 否定的否定为肯定
![image](https://img2022.cnblogs.com/blog/2515183/202204/2515183-20220428142216411-426558078.png)
3.5.2 布尔类(Boolean 类)
// 布尔类(Boolean 类)是一种布尔型的包装类型。
// 其地位以及使用方法和 String 类以及 Number 类相同。
// 像下面这样对布尔值使用点运算符的话,
// 就能够对布尔值进行隐式数据类型转换,将其转为布尔对象。
// 但是,布尔类中并没有什么实用的方法,所以基本上也很少会去使用
console.log("隐式数据类型转换为了Boolean对象:");
console.log(true.toString());
![image](https://img2022.cnblogs.com/blog/2515183/202204/2515183-20220427200549336-144640681.png)
3.5.3 Boolean 类的功能
Boolean 类的函数以及构造函数调用
![image](https://img2022.cnblogs.com/blog/2515183/202204/2515183-20220427200133600-955311685.png)
Boolean 类的属性
![image](https://img2022.cnblogs.com/blog/2515183/202204/2515183-20220427200238614-1772281651.png)
Boolean.prototype 对象的属性
![image](https://img2022.cnblogs.com/blog/2515183/202204/2515183-20220427200316993-850490377.png)
Boolean 类的实例属性
![image](https://img2022.cnblogs.com/blog/2515183/202204/2515183-20220427200406642-1966099443.png)