Created
March 17, 2016 00:09
-
-
Save stavros-zavrakas/ee7a1d6686312da6415b to your computer and use it in GitHub Desktop.
Get type
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
var objectPrototype = Object.prototype; | |
function getType(val) { | |
return objectPrototype.toString.apply(val).match(/\[object\s(\w+)\]/)[1]; | |
} | |
getType("Stavros"); | |
getType(true); | |
getType(24); | |
getType([]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment