Created
August 19, 2014 11:39
-
-
Save Nate-Wilkins/0e347b57a3e6d150edeb to your computer and use it in GitHub Desktop.
typeof
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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