Метод класса JS называется, когда страница загружается
// The cnstructor Method runs when you call a class method
// So for example
class App () {
constructor() {}
logHello() {
console.log("Hello World");
}
}
const test = new App();
// Immediately you have an instance of that class The constructor
// method is called, so if you want the logHello to log immediately then you can
// call it in the constructor like this
class App () {
constructor() {
this.logHello();
}
logHello() {
console.log("Hello World");
}
}
/* This will work on page load because any code not inisde a function or anything
runs on page load */
// Hope you understand and it helps
Good Grebe