JavaScript has the concept of “run to completion”. Unless an error is thrown, a function is executed until a return
statement or its end is reached. Other code outside of the function can’t interfere with that (unless, again, an error is thrown).
If you want resolve()
to exit your initializer function, you have to prepend it by return
:
return new Promise(function(resolve, reject) {
return resolve();
console.log("Not doing more stuff after a return statement");
});