【JS】ES5 语法实现继承

构造函数 A

function A() {
    
}

构造函数 B

function B() {
    A.call(this);
}

修改 B 的原型对象

B.prototype = new A();
// contructor 指向原来的构造函数 B
B.prototype.constructor = B; 
posted @ 2022-12-13 23:23  HypoPine  阅读(17)  评论(0编辑  收藏  举报