function A( age, name ){
this.age = age;
this.name = name;
}
A.prototype.show = function(){
alert('父级方法');
}
function B(age,name,job){A.apply( this, arguments );
this.job = job;
}
B.prototype = new A();
var b = new A(14,'侠客行');
var a = new B(15,'狼侠','侠客');
文章展示了JavaScript中如何使用构造函数functionA和functionB,以及原型链实现对象的继承。functionB通过调用A.apply并设置prototype来继承functionA的方法,然后定义了新的属性job。实例对象a和b分别展示了不同构造函数的用法。

被折叠的 条评论
为什么被折叠?



