1/* Even though the return value of an async function behaves as if it's wrapped in a
2Promise.resolve, they are not equivalent. */
3
4//For example, the following:
5async function foo() {
6 return 1
7}
8
9//...is similar to:
10function foo() {
11 return Promise.resolve(1)
12}
13
14/*An async function will return a different reference, whereas Promise.resolve returns the
15same reference if the given value is a promise.*/
16const p = new Promise((res, rej) => {
17 res(1);
18})
19
20async function asyncReturn() {
21 return p;
22}
23
24function basicReturn() {
25 return Promise.resolve(p);
26}
27
28console.log(p === basicReturn()); // true
29console.log(p === asyncReturn()); // false