标签:
//父亲
function Father(name) {
this.fatherName = name;
}
Father.prototype.age = 18;
var ft = new Father("父亲");
console.info(ft.age);
console.info(ft.fatherName);
//儿子
function Son(name) {
this.sonName = name;
}
Son.prototype = new Father();
//每一个对象的_proto_都来自于构造函数的prototype属性
var sn = new Son("儿子");
console.info(sn.age);
console.info(sn);
标签:
原文地址:http://www.cnblogs.com/wangshuaiF26/p/5551262.html