I have created two classes:
class MyFirstClass {
constructor(fname, lname, date) {
this.fname = fname;
this.lname = lname;
this.date = date;
}
}
class MySecondClass extends MyFirstClass {
constructor(id, optionalArg) {
super();
this.id = id;
}
}
And then created two objects like this:
let myFirstObj = new MyFirstClass("foo", "bar", "today");
let mySecondObj = new MySecondClass(1234); //***(1234, optionalArg)
Now, there are several ways to actualy pass properties from first class to another (or from first obj to second), but whatever I do second object doesnt REFER to the first one, it just creates its own "copy" of properties. So when I do this:
mySecondObj.fname = "someothername";
first object doesnt change - its not referenced to the second one (or the other way - doesnt work either). My question is: How to solve this "conection" on classes (or out of them) to actualy reference new objects one to another? I want to make it as simple as possible (thats why I left optional argument in second class).