my problem is why loop in side of the promise works like sync code for example
console.log('im working')
function proLoop(){
return new Promise((resolve ,rejects)=>{
for (let i = 0; i < 1000000000000; i++) {}
console.log('loop is done')
})
}
proLoop();
console.log('im working')
So even if we write is like promise it will get more time and freezes our code In other words it will works synchronically so why its happening and how to solve it ?
Update
i find a solution but why it works?
so the solution is just warp your code as like resolved promise
like this
return Promise.resolve().then( ()=>{
for (let i = 0; i < 1000000000000; i++) {}
console.log('loop is done')
})
but why???