Skip to content

Instantly share code, notes, and snippets.

Created July 28, 2013 12:16
Show Gist options
  • Save anonymous/6098377 to your computer and use it in GitHub Desktop.
Save anonymous/6098377 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]" />
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
</body>
</html>
function clone(o) {
function F() {}
F.prototype = o;
return new F();
}
SubType.prototype = clone(SuperType.prototype);
SubType.prototype.constructor = SubType;
function SuperType() {
this.color = 'blue';
}
SuperType.prototype.wheels = 4;
function SubType() {
SuperType.call(this);
this.color = 'white';
}
SubType.prototype.wheels = 6;
var myObj = new SubType();
console.log(myObj.color);
console.log(myObj.wheels);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment