I'm trying to understand why this piece of code doesn't behave as I expect:
async function test() {
await setTimeout(() => {
console.log('done')
}, 1000)
console.log('it finished');
}
test();
This first prints it finished
and then prints done
afterwards. Shouldn't this code wait for the timeout to finish before executing console.log('it finished');
or have I misunderstood something?