Skip to content

Instantly share code, notes, and snippets.

@Nate-Wilkins
Created August 19, 2014 11:39
Show Gist options
  • Save Nate-Wilkins/0e347b57a3e6d150edeb to your computer and use it in GitHub Desktop.
Save Nate-Wilkins/0e347b57a3e6d150edeb to your computer and use it in GitHub Desktop.
typeof
function t(obj) {
var typeString = ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1];
if(typeString == "Object"){ return f(obj.constructor); }
else{ return typeString; }
}
function f(m){
return m.name || m.toString().match(/function\s+([^(]+)/)[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment