boolean can be detected with typeof
according to mdn `typeof` return string boolean for the boolean type (`true` and `false) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof
This commit is contained in:
parent
27d15f40bd
commit
9b9e7aeee4
1 changed files with 4 additions and 4 deletions
8
index.js
8
index.js
|
|
@ -11,15 +11,15 @@ const is = value => {
|
|||
return 'null';
|
||||
}
|
||||
|
||||
if (value === true || value === false) {
|
||||
return 'boolean';
|
||||
}
|
||||
|
||||
const type = typeof value;
|
||||
|
||||
if (type === 'undefined') {
|
||||
return 'undefined';
|
||||
}
|
||||
|
||||
if (value === 'boolean') {
|
||||
return 'boolean';
|
||||
}
|
||||
|
||||
if (type === 'string') {
|
||||
return 'string';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue