I understand the promise object

Reference: Promise object in Ruan Yifeng's es6 book

The so-called Promise is simply a container that holds the result of an event (usually an asynchronous operation) that will end in the future. Syntactically, a Promise is an object from which a message for an asynchronous operation can be obtained. Promises provide a unified API, and various asynchronous operations can be handled in the same way.

Promise.prototype = {
  then: function(resolve,reject){},
  catch: function(error){},//catch方法是.then(null,rejection)的别名,用于指定发生错误时的回调函数
  all: function([p1,...]){},//all方法用于将多个 Promise 实例,包装成一个新的 Promise 实例
  race: function(){},
  resolve: function(){},
  reject: function(){}
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325692679&siteId=291194637