Disadvantages and solutions of JS promise
Take an example
I want to print 1 after 1s, 2 after 1s, and 3 after 3s
Traditional asynchronous programming implementation
console.log(new Date)
setTimeout(()=>{
console.log(new Date,1)
setTimeout(()=>{
console.log(new Date,2)
setTimeout(()=>{
console.log(new Date,3)
},3000)
},2000)
},1000)
Promise implement ...
Posted by jonoc33 on Fri, 24 Sep 2021 14:45:04 +0200