# Promise
当async标记的函数 那么这个函数执行后的返回值默认为一个 promise.resolve
  const fn=async()=>{
            return 'hello'
     };
     console.log(fn());//Promise {<fulfilled>: "hello"}
1
2
3
4
2
3
4
- 注意与在Promise中直接返回return不同
  new Promise((resolve, reject) => {
        return 'hello'
      })
      .then(
          (res) => {
        console.log(res);
      });//这里的函数不会执行
1
2
3
4
5
6
7
2
3
4
5
6
7
- 注意在Promise.then中如果return一个数 则相当于resolve这个数
new Promise((resolve, reject) => {
    return resolve('hello')
})
    .then(
        (res) => {
            return res
        }).then((res) => {
            console.log(res);
        })
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
