es6 promise 面试题
程序员文章站
2023-12-21 23:14:46
...
写出下面结果
const promise = new Promise((resolve, reject) => {
console.log(1)
resolve()
console.log(2)
})
promise.then(() => {
console.log(3)
})
console.log(4)
// 答案:1243
let a = () => {
console.log(1)
}
let b = () => {
console.log(2)
}
function fn() {
a()
setTimeout(() => {
b()
}, 0);
console.log(3)
}
fn() // 132