Skip to content

Instantly share code, notes, and snippets.

@jonathantneal
Created July 26, 2012 02:38
Show Gist options
  • Save jonathantneal/3179929 to your computer and use it in GitHub Desktop.
Save jonathantneal/3179929 to your computer and use it in GitHub Desktop.
Object.getClass // returns the class name of an object
Object.getClass = function (object) {
return object === undefined ? "Undefined"
: object === null ? "Null"
: (String.toString.call(object.constructor || object).match(/\s\w+/) || [" Function"])[0].slice(1);
};
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