Immediately-Invoked Function Expression:
(async (myVal) => {
try {
// stuff
} catch (err) {
console.log(err);
}
})(myVal)
Thenable:
Promise.resolve()
.then(async (myVal) => {
// stuff
})
.catch((err) => {
console.log(err);
});
The self-invoked runs quicker. Other than that, any specific advantage to utilize one over the other and in which situations?
Some other differences:
myVal instead of undefined for the local myVal variablePromise or its methodsIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With