Skip to content

Latest commit

 

History

History
26 lines (17 loc) · 602 Bytes

isBoolean.md

File metadata and controls

26 lines (17 loc) · 602 Bytes
标题 标签
isBoolean(判断是否是布尔值) type(类型)

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

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

调用方式:

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

应用场景

结果如下:

<iframe src="codes/javascript/html/isBoolean.html"></iframe>