判断一个值是否是基本布尔类型并,基本布尔类型有true和false。如果是,则返回true;
function boo(bool)
{
if(typeof bool=="boolean"){
return bool?true:true;
}else return false;
}
附:常见typeof类型返回结果
alert(typeof 1); // 返回字符串"number"
alert(typeof "1"); // 返回字符串"string"
alert(typeof true); // 返回字符串"boolean"
alert(typeof {}); // 返回字符串"object"
alert(typeof []); // 返回字符串"object "
alert(typeof function(){}); // 返回字符串"function"
alert(typeof null); // 返回字符串"object"
alert(typeof undefined); // 返回字符串"undefined"
alert(typeof NaN); // 返回字符串"number"