标签:new console res 新建 ons log ISE 循环 事件
const promise = new Promise((resolve, reject) => { console.log(1); resolve(); console.log(2); }) promise.then(() => { console.log(3); }) console.log(4);
以上输出结果为1243
首先Promise新建后立即执行,所以会先输出1,2,而Promise.then()内部的代码在当次事件循环的结尾立即执行,所以会先输出4,最后输出3.
标签:new console res 新建 ons log ISE 循环 事件
原文地址:https://www.cnblogs.com/dylAlex/p/11093168.html