Recently, I read a post about the best practice for using Promise
. The article calls it a "side effect" when we call a function inside the .then()
without actually returning a result.
somePromise().then(function () {
someOtherPromise();
}).then(function () {
// Gee, I hope someOtherPromise() has resolved!
// Spoiler alert: it hasn't.
});
Generally, I understand why it's a good practice using the return
keyword other than just calling the function. But I'm still curious why we use the phrase "side effect" here.