JSFiddle - React, Tailwind, and code Playground
by Abdul Ahmad
JavaScript
function async(cb) {
return new Promise((res) => {
setTimeout(() => {
cb();
res();
}, 1000);
});
}
class One {
hiMessage = 'hi';
byeMessage = 'bye';
constructor() {
this.sayBye = this.say.bind(this);
}
sayHi() {
async(this.sayBye);
}
sayBye() {
console.log(this.byeMessage);
}
}
const o = new One();
o.sayHi();