I define a class as follows:
class Person {
constructor() {
this.age = 60;
}
showAge() {
return console.log(this.age);
}
}
const mark = new Person();
mark.showAge(); //60
How do I change this.age
that the object mark will initialize with from 60 to another number without simply assigning a new value in the constructor?
The idea is to then create new objects from the class which all instantiate with this new value and not 60 for this.age
.