http://es6.ruanyifeng.com/#do...这个是阮一峰老师关于Promise.resolve()参数的解读,其中参数是thenable对象时,Promise.resolve方法会将这个对象转为Promise对象,然后就立即执行thenable对象的then方法。问题来了:newPromise(resolve=>{resolve(1);Promise.resolve({then:function(resolve,reject){console.log(2);resolve(3)}}).then(t=>console.log(t))console.log(4);}).then(t=>console.log(t));console.log(5);控制台输出:45213下面按照最开始的理解,将上述代码进行转换newPromise(resolve=>{resolve(1);newPromise(resolve=>{console.log(2);resolve(3)}).then((t)=>console.log(t));console.log(4);}).then(t=>console.log(t));console.log(5);控制台输出24531顺序不一样。。我很崩溃求解答
红颜莎娜
相关分类