The first of the below code examples is what I am doing today, where I initialise the global variables in the constructor.
But would there be any harm in moving the global variables out in the class, as seen in the second example?
class Alert {
constructor(alert) {
this.load = JSON.parse('{}');
this.alert = alert;
this.#coolDownTime = 0;
};
#coolDownTime;
}
vs just doing
class Alert {
constructor(alert) {
this.alert = alert;
};
#coolDownTime = 0;
#load = JSON.parse('{}');
}