Update and rename check_for_boolean.md to check-for-boolean-primitive-values.md
This commit is contained in:
8
snippets/check-for-boolean-primitive-values.md
Normal file
8
snippets/check-for-boolean-primitive-values.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
### Check for boolean primitive values
|
||||||
|
|
||||||
|
Use `typeof` to check if a value is classified as a boolean primitive.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const isBool = val => typeof val === 'boolean';
|
||||||
|
// isBool(null) -> false
|
||||||
|
```
|
||||||
@ -1,10 +0,0 @@
|
|||||||
### Check for Boolean Primitive Values
|
|
||||||
|
|
||||||
Check if a value is classified as a boolean primitive. Return true or false.
|
|
||||||
|
|
||||||
function booWho(bool) {
|
|
||||||
return typeof bool === 'boolean';
|
|
||||||
}
|
|
||||||
|
|
||||||
// test here
|
|
||||||
booWho(null);
|
|
||||||
Reference in New Issue
Block a user