Skip to content

Instantly share code, notes, and snippets.

@alanerzhao
Created November 6, 2013 10:06
Show Gist options
  • Save alanerzhao/7333686 to your computer and use it in GitHub Desktop.
Save alanerzhao/7333686 to your computer and use it in GitHub Desktop.
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