📅  最后修改于: 2022-03-11 15:03:58.178000             🧑  作者: Mango
// 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