Skip to content

Instantly share code, notes, and snippets.

@flawyte
Created February 17, 2015 10:18
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 flawyte/f467420b4c5ea4f48ffb to your computer and use it in GitHub Desktop.
Save flawyte/f467420b4c5ea4f48ffb to your computer and use it in GitHub Desktop.
Returns a string representation of an object's exact type (e.g. "HTMLInputElement", "String", "Number", "Array"... or "Object" for plain objects).
function type(p) {
return Object.prototype.toString.call(p)
.match(/\[object (.*)\]/)[1];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment