I have lot of confusion in promise. It\'s a synchronous or asynchronous ?
return new Promise (function(resolved,reject){ //sync or async? }); >
return new Promise (function(resolved,reject){ //sync or async? });
This code makes it clearer:
console.log("0"); new Promise((resolve, reject) => { console.log("1"); resolve(); }).then(() => { console.log("2"); }); console.log("3");
The code prints: 0 1 3 2 So, then runs asynchronously while the main call back function runs synchronously.
0 1 3 2
then