Skip to content

Instantly share code, notes, and snippets.

@eriwen
Created September 22, 2011 13:35
Show Gist options
  • Save eriwen/1234782 to your computer and use it in GitHub Desktop.
Save eriwen/1234782 to your computer and use it in GitHub Desktop.
Fixing typeof by Angus Croll
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