Created
May 21, 2009 07:40
-
-
Save joshprice/115333 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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