1async function testSometing() {
2 console.log("执行testSometing");
3 return "testSometing";
4}
5
6async function testAsync() {
7 console.log("执行testAsync");
8 return Promise.resolve("hello async");
9}
10
11async function test() {
12 console.log("test start...");
13 const v1 = await testSometing();
14 console.log(v1);
15 const v2 = await testAsync();
16 console.log(v2);
17 console.log(v1, v2);
18}
19
20test();
21
22var promise = new Promise(resolve => {
23 console.log("promise start...");
24 resolve("promise");
25});
26promise.then(val => console.log(val));
27
28console.log("test end...");
29