Boo who

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

基本布尔类型即 true 和 false。

注意: 
typeof operand

  • typeof操作符返回操作数的类型(字符串)
  • operand是一个表达式,表示对象或原始值,返回其类型
  • 例如:typeof 3.14 === ‘number’;typeof “bla” === ‘string’;typeof true === ‘boolean’;
  • typeof new String(“abc”) === ‘object’;typeof Math.sin === ‘function’;
  • typeof undefined === ‘undefined’;typeof [1, 2, 4] === ‘object’;
function boo(bool) {
  // What is the new fad diet for ghost developers? The Boolean.
  //typeof bool 返回bool的类型,即boolean
  return typeof bool==='boolean';
}

boo(1);
原文地址:https://www.cnblogs.com/fffangrui/p/6110420.html