Last active
April 21, 2019 07:16
-
-
Save mebtte/88d2209d9436bb3d6c4d330846f398cc to your computer and use it in GitHub Desktop.
Get the type of value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get the type of value. | |
* @author mebtte<[email protected]> | |
* @param {Any} [value] value | |
* @return {String} enum(Undefined, Null, Boolean, Number, String, Symbol, Object, Function, Array, Set, WeakSet, Map, WeakMap, NodeList) | |
*/ | |
function typeOf(value) { | |
return Object.prototype.toString.call(value).match(/\[object (\S*)\]/)[1]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment