Skip to content

Instantly share code, notes, and snippets.

@jaredatron
Created April 2, 2010 16:38
Show Gist options
  • Save jaredatron/353347 to your computer and use it in GitHub Desktop.
Save jaredatron/353347 to your computer and use it in GitHub Desktop.
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