I wrote a minimal JavaScript class that accepts 2 parameters for the constructor as follows:
class myClass {
constructor(name, age) {
this.name = name;
this.age = age;
}
startProcess() {
// call other functions that use this.name and this.age
}
}
var init = new myClass('John', 29);
init.startProcess();
Is there a way to remove the John and 29 parameters when initializing myClass and add them to init.startProcess? I still want those parameters to be accessible from other functions.
Basically, I want to do this and keep the same functionality.
var init = new myClass();
init.startProcess('John', 29);