Skip to content

Instantly share code, notes, and snippets.

@mebtte
Last active April 21, 2019 07:16
Show Gist options
  • Save mebtte/88d2209d9436bb3d6c4d330846f398cc to your computer and use it in GitHub Desktop.
Save mebtte/88d2209d9436bb3d6c4d330846f398cc to your computer and use it in GitHub Desktop.
Get the type of value.
/**
* 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