Skip to content

Instantly share code, notes, and snippets.

@joshprice
Created May 21, 2009 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshprice/115333 to your computer and use it in GitHub Desktop.
Save joshprice/115333 to your computer and use it in GitHub Desktop.
//
// Define this.constructor.name so we can introspect an object for it's constructor's name
// (equivalent to the 'Class' name if there were classes...)
// This is necessary because IE does not define this constructor property but FF does.
//
Function.prototype.getName = function() {
var matches = this.toString().match(/function\s+([\w\$]+)\s*\(/);
return matches ? matches[1] : '';
};
Function.prototype.bind = function(context) {
var method = this;
return function() {
return method.apply(context, arguments);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment