问答题848/1593【Promise第35题】下面代码的输出是什么?

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
难度:
2022-01-09 创建

参考答案:

这儿直接给出答案:

'test start...'
'执行testSometing'
'promise start...'
'test end...'
'testSometing'
'执行testAsync'
'promise'
'hello async'
'testSometing' 'hello async'

最近更新时间:2022-01-09

赞赏支持

预览

题库维护不易,您的支持就是我们最大的动力!