Adi – 10-07 May 14

Can I have async method which is used in constructor for intialization? something like this:
class Foo {
constructor () {
this.initialize();
}

async initialize () {

const res = await randomMethod();
const res2 = await randomMethod2();

}
}
const bar = new Foo();
class Foo {
constructor () {
this.initialize();
}

async initialize () {

const res = await randomMethod();
const res2 = await randomMethod2();

}
}
const bar = new Foo();
Do I need to use await this.initialize(); I checked the code without await also it is working
UU
Unknown User705d ago