基本类型布尔值的检查

检查一个值是否是基本类型中的布尔值(boolean)类型。 函数应返回 true 或者 false。基本类型中的布尔值为 true 或者 false

1 function booWho(bool) {
2   return typeof bool ==='boolean';
3 }
4 booWho(null);

 typeof 操作符返回一个字符串,表示未经计算的操作数的类型

1 typeof operand
2 typeof(operand)
1 function booWho(bool) {
2   return  bool === true || bool === false;
3 }
4 booWho(null);

 

posted @ 2021-05-16 21:33  icyyyy  阅读(268)  评论(0)    收藏  举报