Added isX functions

This commit is contained in:
Angelos Chalaris
2017-12-14 12:56:02 +02:00
parent 6abffae5c4
commit 3aa0c5eec0
7 changed files with 100 additions and 18 deletions

View File

@ -1,8 +0,0 @@
### 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
```

9
snippets/is-boolean.md Normal file
View File

@ -0,0 +1,9 @@
### Is boolean
Use `typeof` to check if a value is classified as a boolean primitive.
```js
const isBoolean = val => typeof val === 'boolean';
// isBoolean(null) -> false
// isBoolean(false) -> true
```

9
snippets/is-function.md Normal file
View File

@ -0,0 +1,9 @@
### Is boolean
Use `typeof` to check if a value is classified as a function primitive.
```js
const isFunction = val => val && typeof val === 'function';
// isFunction('x') -> false
// isFunction(x => x) -> true
```

9
snippets/is-number.md Normal file
View File

@ -0,0 +1,9 @@
### Is number
Use `typeof` to check if a value is classified as a number primitive.
```js
const isNumber = val => typeof val === 'number';
// isNumber('1') -> false
// isNumber(1) -> true
```

9
snippets/is-string.md Normal file
View File

@ -0,0 +1,9 @@
### Is string
Use `typeof` to check if a value is classified as a string primitive.
```js
const isString = val => typeof val === 'string';
// isString(10) -> false
// isString('10') -> true
```

9
snippets/is-symbol.md Normal file
View File

@ -0,0 +1,9 @@
### Is symbol
Use `typeof` to check if a value is classified as a symbol primitive.
```js
const isSymbol = val => typeof val === 'symbol';
// isSymbol('x') -> false
// isSymbol(Symbol('x')) -> true
```