Added getType function

This commit is contained in:
macsmac
2017-12-13 00:33:36 +05:00
parent 292411a812
commit 4f8bbf4733

View File

@ -261,6 +261,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`.