Async is used to declare that a function is asynchronous, and await is used to wait for an asynchronous method to complete. Await can be understood as the then method of a promise, which is regarded as a microtask.

function test(msg) {
 return new  Promise(resolve= > {
     setTimeout(() = >{
         resolve(msg)
     },200)})}async  function  testAsync(){
  const x  =  await test('Hello, new friend! ')
    console.log(x)
    console.log('Welcome to my world')
}
testAsync().then()  // Hello, new friend! Welcome to my world
Copy the code

Resolve (resolve); resolve (test);