美文网首页
FCC-Boo who

FCC-Boo who

作者: zooeydotmango | 来源:发表于2017-11-17 17:18 被阅读0次

检查一个值是否是基本布尔类型,并返回 true 或 false。
基本布尔类型即 true 和 false。

function boo(bool) {
  // What is the new fad diet for ghost developers? The Boolean.
  return (typeof bool )=== 'boolean';
//return bool === Boolean(bool);
}
boo(null);

题目本身很简单,下面是扩展,检查值是否指定类型Object.prototype.toString();返回对象所属类的名称

function isType(value,type){
var res=Object.prototype.toString.call(value);
return res === '[Object'+type+']';
}

还可以用正则优化,忽略第二个参数的大小写

相关文章

  • FCC-Boo who

    检查一个值是否是基本布尔类型,并返回 true 或 false。基本布尔类型即 true 和 false。 题目本...

  • 2017-07-18

    Who?Who?Who? Yes!It is him!

  • Who miss who

    key words:鱼贩 爱情 香港 miss 先从鱼贩说起。本人爱吃点鱼肉,又为减肥和健康起见,所以光顾鱼摊点是...

  • Who will remember who

    People will meet all kinds of people in their lives It's ...

  • 2018-05-01

    My Mother Who is the one who take care of me? Who is the ...

  • 每天一个Linux 命令 - who

    who who - show who is logged on Print information about...

  • 老师你辛苦了

    Who taught us? Who taught us to be grateful? Who taught u...

  • 用户及文件权限管理

    一:查看用户 $who am i 或 $who mom likes 或 $who -m who 命令及其他常用参数...

  • Who are rich? Who are poor? ---

    Who are rich? Who are poor? ----Nine universitie...

  • who怕who啊??!!

    亲爱的猪猪宝贝: 你现在是睡着了,此刻已经22:23了!又到了作业雨的日子,时间过得真是不要太快了! 今天咱们回了...

网友评论

      本文标题:FCC-Boo who

      本文链接:https://www.haomeiwen.com/subject/lsijvxtx.html