function het(ball){
setTimeout(() => {
let name = "wuguotong"
ball(name)
}, 500);
}
het(function(a){
console.log("收到异步操作的数据是:"+a)
})
promise方式:
let p = new Promise((res,rej)=>{
setTimeout(() => {
let name = "wuguotong"
res(name)
}, 1000);
})
p.then((data)=>{
console.log("通过promise获取的异步操作数据为:"+data)
})