Inheritance and module pattern

后端 未结 2 1247
傲寒
傲寒 2020-12-15 01:15

I\'m trying to implement the inheritance with the module pattern in this way:

Parent = function () {

    //constructor
    (function construct () {
                 


        
2条回答
  •  庸人自扰
    2020-12-15 02:04

    (function () {
        console.log("Child");
        Parent.call(this, arguments);
        this.prototype = Object.create(Parent.prototype);
    })();
    

    this refers to window, because you wrapped your code into a function. Remove the wrapping function or pass this as argument.

提交回复
热议问题