I need to execute all methods in random order from main_method (i will create a class instance later).
But when first function start executing it shows that "this" inside her is equal undefined.
How can i fix this? Thx
class test {
construstor(smth) {
this.smth = smth
}
async main_method {
for (let func of [this.#method1, this.#method2, this.#method3].sort(() => Math.random() - 0.5 )) {
await func(this.smth);
}
}
async #method1(smth) {
// this === undefined
///
}
async #method2(smth) {
// this === undefined
///
}
async #method3(smth) {
// this === undefined
///
}
}