function tes0t() {
fn1();
fn2(1, 1, () => {fn3();});
}
function fn1() {
console.log(1);
}
function fn2(n1, n2, n3) {
setTimeout(function () {
console.log(2);
if (n3) n3.call();//返回值的设置
}, 1000);
}
function fn3() {
setTimeout(function () {
console.log(3);
}, 0);
}
tes0t();
async/await-Promise-让异步操作同步执行
function fn4(){
return new Promise(resolve=>{
setTimeout(function(){
msg='等啥 '
resolve(msg)
},1000)
})
}
async function aC(){
var result = await fn4();
console.log(result);
}
aC()
function tes0t() {
fn1();
fn2(1, 1, () => {fn3();});
}
function fn1() {
console.log(1);
}
function fn2(n1, n2, n3) {
setTimeout(function () {
console.log(2);
if (n3) n3.call();//返回值的设置
}, 1000);
}
function fn3() {
setTimeout(function () {
console.log(3);
}, 0);
}
tes0t();
async/await-Promise-让异步操作同步执行
function fn4(){
return new Promise(resolve=>{
setTimeout(function(){
msg='等啥 '
resolve(msg)
},1000)
})
}
async function aC(){
var result = await fn4();
console.log(result);
}
aC()