Timing of async/await and promise.then execution

1
function  GenFunc () {
  new Promise(function(resolve) {
        resolve()
    }).then(function() {
        console.log("1")
    })
  console.log("2")
}
GenFunc()
// 
// 2
// 1
2
async function  GenFunc () {
  new Promise(function(resolve) {
        resolve()
    }).then(function() {
        console.log("1")
    })
    await "string";
    console.log("2")
}
GenFunc()
// 
// 1
// 2

ask why await changed the order of execution. Promise.then belongs to microtasks. Synchronize"s code will not enter microtasks until it has been executed. So what is the reason for the inconsistency between the two pieces of code

Mar.19,2021

since the subject himself mentioned microtask, I assume that the subject already knows what is going on in example 1
await in

async will put the following code into the new microtask, even if what you are waiting for is actually Synchronize .

< hr >

detailed parsing:

(async function GenFunc() {
  new Promise(function constructPromise(resolve) { // 1. PromiseconstructPromise
    resolve()                                      // 2. resolvepromiseCallbackmicrotask1
  }).then(function promiseCallback() {
    console.log('1')                               // 6. microtask1
  })
  await 'string'                                   // 3. awaitmicrotask2
  console.log('2')                                 // 7. microtask2
})()                                               // 4. async call returnPromise<pending>
console.log('3')                                   // 5. 
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9c9cc-18f4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9c9cc-18f4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?