Skip to content

Instantly share code, notes, and snippets.

@luke-gru
Created July 15, 2011 03:15
Show Gist options
  • Save luke-gru/1083984 to your computer and use it in GitHub Desktop.
Save luke-gru/1083984 to your computer and use it in GitHub Desktop.
function child_of(o) {
function F() {}
F.prototype = o;
return new F();
}
function Obj() {
this.speed = 10;
}
Obj.prototype = new Object;
Obj.prototype.constructor = Object;
var car1 = new Obj();
print(car1.speed);
car2 = child_of(car1);
print(car2.speed);
@luke-gru
Copy link
Author

functionality to inherit from old instance of 'class', not new instance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment