Created
December 25, 2012 23:37
-
-
Save jasdeepkhalsa/4376385 to your computer and use it in GitHub Desktop.
Check JavaScript variable type with the .toString method by ExampleJS.com
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 isType(arg, type) { | |
type = type.charAt(0).toUpperCase() + type.substr(1); | |
return Object.prototype.toString.call(arg) == '[object ' + type + ']'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment