I am taking this free course that about JavaScript Promises. In lesson 7, here is the video, there is a code snippet :
new Promise(function(resolve) {
console.log('first');
resolve();
console.log('second');
}).then(function() {
console.log('third');
});
When I run this code in console it returns:
->first
->second
->third
As far as I know, when we call the resolve, the then method should be run at that moment. So I expect:
->first
->third
So as far as I know, when we call the resolve it should jump to the then method and "console.log("second")
" statement shouldn't have been executed.
Can somebody explain how promises behave after encountered with resolve method?