Merge pull request #45 from macsmac/master

Added getType function
This commit is contained in:
Angelos Chalaris
2017-12-13 11:31:51 +02:00
committed by GitHub

View File

@ -262,6 +262,15 @@ const arrayMin = arr => Math.min(...arr);
// arrayMin([10, 1, 5]) -> 1
```
### Get native type of value
Returns lower-cased constructor name of value, "undefined" or "null" if value is undefined or null
```js
const getType = v => v === undefined ? "undefined" : v === null ? "null" : v.constructor.name.toLowerCase();
// getType(new Set([1,2,3])) -> "set"
```
### Get scroll position
Use `pageXOffset` and `pageYOffset` if they are defined, otherwise `scrollLeft` and `scrollTop`.