Skip to content

Instantly share code, notes, and snippets.

@localpcguy
Created May 31, 2017 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save localpcguy/b398d95cc90dd2b1a1474c27e5708c41 to your computer and use it in GitHub Desktop.
Save localpcguy/b398d95cc90dd2b1a1474c27e5708c41 to your computer and use it in GitHub Desktop.
Get the class type of a JavaScript element
function getClass(obj) {
if (typeof obj === 'undefined') {
return 'undefined';
}
if (obj === null) {
return 'null';
}
return Object.prototype.toString.call(obj).match(/^\[object\s(.*)\]$/)[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment