JSFiddle - React, Tailwind, and code Playground
HTML
Look in the console.
JavaScript
class Example {
constructor() {
console.log("constructor called");
return new Promise(resolve => {
setTimeout(() => {
console.log("resolving promise");
const instance = Object.create(Example.prototype);
resolve(instance);
}, 200);
});
}
foo() {
console.log("foo called");
}
}
// Just a top-level wrapper
(async () => {
const e = await new Example();
e.foo();
})().catch(e => { console.error(e); });