Skip to content

Instantly share code, notes, and snippets.

@ghengeveld
Created September 22, 2015 13:07
Show Gist options
  • Save ghengeveld/45ad9138e4a34d2bd935 to your computer and use it in GitHub Desktop.
Save ghengeveld/45ad9138e4a34d2bd935 to your computer and use it in GitHub Desktop.
Get object constructor name (class name) in IE
let getClassName = obj => {
if (obj.constructor.name) {
return obj.constructor.name;
}
const regex = new RegExp(/^\s*function\s*(\S*)\s*\(/);
getClassName = obj => obj.constructor.toString().match(regex)[1];
return getClassName(obj);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment