基本类型布尔值的检查
检查一个值是否是基本类型中的布尔值(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);

浙公网安备 33010602011771号