-
-
Save arsonus/e5b16795d949b80e85c551f3965f03f3 to your computer and use it in GitHub Desktop.
Object.getClass // returns the class name of an object
This file contains hidden or 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
Object.getClass = function (object) { | |
return object === undefined ? "Undefined" | |
: object === null ? "Null" | |
: (String.toString.call(object.constructor || object).match(/\s\w+/) || [" Function"])[0].slice(1); | |
}; |
This file contains hidden or 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
Object.getClass=function(a){return void 0===a?"Undefined":null===a?"Null":(String.toString.call(a.constructor||a).match(/\s\w+/)||[" Function"])[0].slice(1)}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment