Created
July 28, 2013 12:16
-
-
Save anonymous/6098377 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="[add your bin description]" /> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains hidden or 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 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