Created
November 6, 2013 10:06
-
-
Save alanerzhao/7333686 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
function SuperType (name) { | |
this.name = name; | |
this.colors = ['red','blue','green']; | |
} | |
SuperType.prototype.sayName = function () { | |
console.log(this.name); | |
} | |
function SubType(name,age) { | |
SuperType.call(this,name); | |
this.age = age; | |
} | |
SubType.prototype = new SuperType(); | |
SubType.prototype.sayAge = function () { | |
console.log(this.age); | |
} | |
var instance = new SubType("bazi",22); | |
console.log(instance); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment