Skip to content

Instantly share code, notes, and snippets.

@arsonus
Forked from jonathantneal/Object.getClass.js
Created February 6, 2018 21:55
Show Gist options
  • Save arsonus/e5b16795d949b80e85c551f3965f03f3 to your computer and use it in GitHub Desktop.
Save arsonus/e5b16795d949b80e85c551f3965f03f3 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