Promise knowledge Summary

Disclaimer: If you have any objection to this article, then please write your comments in the article comments at. If you find this article interesting, please share and forward, or you can look at, you acknowledge and encouragement of our articles. Wish everyone in the programming this road, farther and farther. https://blog.csdn.net/weixin_44369568/article/details/91458012

Promise

Asynchronous programming is a solution than traditional solutions - more rational and more powerful - callback functions and events.

new promise((resolve,reject)=>{

resolve  成功执行方法

reject   失败执行方法

})

Resolve and reject calls

promise.prototype.then

PromiseObject.then(()=>{

resolve 要执行的函数
},()=>{

reject  要执行的函数
})

decodeURLComponent () support multi-format encoding

decodeURL () less supported encoding formats

Examples plurality promise, packaged into a new instance Promise
Promise.all([Promise1,promise2])
Alternatively catch exceptions second parameter .then
Promise.prototype.catch()
Promise objects regardless of the final status, the operation will be performed
Promise.prototype.finally()
A method for all instances plurality Promise, packaged into a new instance Promise
Promise.prototype.race([promise1,promise2])

As long as there will be a successful execution then

Guess you like

Origin blog.csdn.net/weixin_44369568/article/details/91458012