Skip to content

Instantly share code, notes, and snippets.

@dkordik
Created October 6, 2011 21:13
Show Gist options
  • Save dkordik/1268693 to your computer and use it in GitHub Desktop.
Save dkordik/1268693 to your computer and use it in GitHub Desktop.
Ruby's .class for Javascript... kinda
Object.prototype.class = function () {
var match = this.constructor.toString().match("function " + /([A-Za-z]+)/.source) || this.constructor.toString().match("return new " + /([A-Za-z]+)/.source);
return match[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment