Skip to content

Instantly share code, notes, and snippets.

@esgy
Created November 19, 2012 10:51
Show Gist options
  • Save esgy/4110083 to your computer and use it in GitHub Desktop.
Save esgy/4110083 to your computer and use it in GitHub Desktop.
javascript typeof helper
Object.toType = (function toType(global) {
return function(obj) {
if (obj === global) {
return "global";
}
return ({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
}
})(this)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment