JavaScript对象的继承方式

.原型链继承
function Student(name,age){
    this.name = name;
    this.age = age;
}
Student.prototype.study = function () {

    console.log("Fd");
}

function SmallStudent(name,age){
    //对象冒充继承
    Student.call(this,name,age);
}
//原型链继承:
SmallStudent.prototype = new Student("web",18);

posted @ 2022-09-26 20:42  九毛九  阅读(13)  评论(0)    收藏  举报