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,16 +11,16 @@ const is = value => {
|
||||||
return 'null';
|
return 'null';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value === true || value === false) {
|
|
||||||
return 'boolean';
|
|
||||||
}
|
|
||||||
|
|
||||||
const type = typeof value;
|
const type = typeof value;
|
||||||
|
|
||||||
if (type === 'undefined') {
|
if (type === 'undefined') {
|
||||||
return 'undefined';
|
return 'undefined';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value === 'boolean') {
|
||||||
|
return 'boolean';
|
||||||
|
}
|
||||||
|
|
||||||
if (type === 'string') {
|
if (type === 'string') {
|
||||||
return 'string';
|
return 'string';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue