Last active
August 29, 2015 14:03
-
-
Save rodrei/402c096a88329e9d7b32 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
/* | |
* Creates a new object that uses the old object as its prototype | |
* From: Javascript: the Good Parts | |
*/ | |
if (typeof Object.create !== 'function') { | |
Object.create = function (o) { | |
var F = function () {}; | |
F.prototype = o; | |
return new F(); | |
}; | |
} | |
/* | |
* | |
*/ | |
Function.prototype.method = function (name, func) { | |
this.prototype[name] = func; | |
return this; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment