Inheritance in javascript, variables in the “parent”
问题 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. function TestObject(data) { this.test_array = []; this.clone_array = []; this.dosomestuff = function() { for(var i=0; i<this.test_array.length; i++) { this.clone_array[i]=this.test_array[i]; } } this.__construct = function(data) { console.log("Testing Object Values" ,this.clone_array); this.test_array = data; }; } TestObject2.prototype