Created
April 2, 2010 16:38
-
-
Save jaredatron/353347 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
Function.prototype.construct = function(){ | |
function emptyFunction(){}; | |
emptyFunction.prototype = this.prototype; | |
return new emptyFunction; | |
} | |
Function.prototype.create = function(){ | |
var instance = this.construct(); | |
this.apply(instance, arguments); | |
return instance; | |
} | |
function Frog(name){ | |
this.name = name+' the frog'; | |
} | |
Frog.prototype.is_a_frog = true; | |
dir(new Frog('Sam')) | |
dir(Frog.create('Sam')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment