In the following example, After the Promise is completed and aaa
is printed, then only hello
should be printed. But, it is not happening. Why, as .then
method runs only after Promise is completed.
function printF(item){
return new Promise((resolve, reject) => resolve(setTimeout(function(){console.log('aaa')}, 1000)));
}
printF(10).then(res => console.log('hello'));