/父类
function Fclass(name,age) {
this.name = name;
this.age = age;
}
//放在原型上所有新的实例可以共有这个函数
Fclass.prototype.showName = function () {
alert(this.name);
};
Fclass.prototype.showAge = function () {
alert(this.age);
};
//子类
function Sclass(name,age,job) {
//如果js想要实现继承的话,就要调用父类call方法,把this传进去
//属性的继承
// Fclass.apply(this,[name,age]);
Fclass.call(this,name,age);
this.job = job
}
//方法的继承
Sclass.prototype = new Fclass();
Sclass.prototype.showJob = function () {
alert(this.job);
};
var chile = new Sclass('Jack',18,'老司机');
chile.showName();