Inheritance in javascript, variables in the “parent”

前端 未结 3 1637
隐瞒了意图╮
隐瞒了意图╮ 2020-12-30 10:45

I am doing OO javascript for the first time. I have read about inheritance and prototype and thought I had cracked it. Until I discovered this little example.



        
3条回答
  •  悲&欢浪女
    2020-12-30 11:20

    have you already tried to define this.clone_array = []; into TestObject2 instead?

    function TestObject2(data)
    {
        this.clone_array = [];
        this.__construct(data);
        this.dothings = function()
        {
            this.dosomestuff();
        }
    }
    

提交回复
热议问题