Skip to content

Latest commit

 

History

History
33 lines (20 loc) · 852 Bytes

is-boolean.md

File metadata and controls

33 lines (20 loc) · 852 Bytes
标题 标签
isBoolean(判断是否是布尔值) type(类型)

检查给定参数是否是本机布尔元素。

  • 使用 typeof 检查一个值是否被归类为布尔基元。
const isBoolean = val => typeof val === 'boolean';

ts 代码如下:

调用方式:

isBoolean(null); // false
isBoolean(false); // true

应用场景

以下是一个实战示例:

结果如下:

<iframe src="codes/javascript/html/is-boolean.html"></iframe>