1
async function (){
    // await somthing
}

Uncaught SyntaxError: Unexpected token (

but i can define normal function like

function (){
    // ...
}()
CS QGB
  • 297
  • 1
  • 3
  • 12

2 Answers2

1

You need a function name for this syntax :

async function functionName(){
    // await somthing
}

You can use this syntax too if you don't want to name it :

async () => {
  //await something
}
1

define an [anonymous] function and call immediately,parentheses needed

(async function (){
  return 1
}) () // and call it , Promise {<resolved>: 1}

CS QGB
  • 297
  • 1
  • 3
  • 12