ES6中的Promise.resolve()的作用

var foo = {
    then: (resolve, reject) => resolve('foo')
};
var resolved = Promise.resolve(foo);
相当于
var resolved = new Promise((resolve, reject) => {
    foo.then(resolve, reject)
});

resolved.then((str) => 
    console.log(str);//foo
)

  

原文地址:https://segmentfault.com/q/1010000005330351

posted @ 2018-04-10 10:38  生如逆旅,一苇以航  阅读(19255)  评论(1编辑  收藏  举报