I have a problem node.js structure with javascript oop. I created a class using another class.
var base = function (name) {
this.Rows = new Array();
};
var top = function (name) {
this.name = name;
};
top.prototype = new base();
var myClass = new top("");
myClass.Rows.push("a");
console.log(myClass.Rows);
var myClass2 = new top("test");
myClass2.Rows.push("b");
console.log(myClass2.Rows);
This code returns the following results;
[ 'a' ]
[ 'a', 'b' ]
but I do not have to be found by the algorithm as the result of this code?
[ 'a' ]
[ 'b' ]
Thank you for helping.
solved: i solved this problem. refactoring code;
var base = function (name) {
this.Rows = new Array();
}
var top = function(name) {
top.prototype.constructor.call(this, name);
this.name = name;
}
top.prototype = Object.create(new base());
thanks for all.