文章出處
【javaScript學習之二——typeof用法】判斷一個值是否是基本布爾類型并,基本布爾類型有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"
看文倉www.kanwencang.com網友整理上傳,為您提供最全的知識大全,期待您的分享,轉載請注明出處。
歡迎轉載:http://www.kanwencang.com/bangong/20170309/115811.html
文章列表
全站熱搜