I'm programming with javascript and I stumbled on this code I wonder how and why the code below works:
var test = async () => {
  console.log("before");
  await setTimeout(() => {
    console.log("after");
  }, 1000);
};
test();
It log's this:
- "before"
- "after"
This is a sample code, but my question is how is this working? setTimeout() doesn't return a Promise (I think) so the async/await pair should not work or is something that I'm missing?
 
     
    