Promise
// function fun(){
// return new Promise((res,rej)=>{
// res(1);
// rej(3)
// })
// }
// fun().then((a)=>{
// console.log(a)
// }).catch((b)=>{
// console.log(b)
// })
// async和await
// function 摇色子(){
// let a=parseInt(Math.random()*6+1)
// return new Promise((res)=>{
// setTimeout(()=>{
// res(a)
// },3000)
// })
// }
// async function test(){
// let n=await 摇色子()
// console.log(n)
// }
// test()
// function 摇色子(猜测) {
// return new Promise((res, rej) => {
// let a = parseInt(Math.random() * 6 + 1)
// if (a > 3) {
// if (猜测 === ‘大‘) {
// res(a)
// } else {
// rej(a)
// }
// } else {
// if (猜测 === ‘大‘) {
// rej(a)
// } else {
// res(a)
// }
// }
// setTimeout(() => {
// res(a)
// }, 300)
// })
// }
// async function test() {
// try {
// let n = await 摇色子(‘大‘)
// console.log(‘赢了‘+n)
// } catch (error) {
// console.log( ‘输了‘+error )
// }
// }
// test()