Methods
getType(valueopt) → {String}
Prod-ready type detection for values, expanding on flawed typeof functionality, roughly following https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof, but expanding on useful frontend types like "htmldocument", "htmlelement", "htmlcollection" and "nodelist"
Types:
- "undefined"
- "null"
- "boolean"
- "number"
- "bigint"
- "string"
- "symbol"
- "function"
- "object"
- "array"
- "date"
- "error"
- "generator"
- "iterator"
- "regexp"
- "set"
- "weakset"
- "map"
- "weakmap"
- "htmldocument"
- "htmlelement"
- "svgelement"
- "htmlcollection"
- "nodelist"
- "window"
- "url"
- "urlsearchparams"
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
* |
<optional> |
variable to check the type of |
Returns:
the value type in lower case
- Type
- String
Example
if( getType(cb) === 'function' ){
...
}