DEV Community

Discussion on: ELI5: Why use a function declaration, expression, or an IIFE in JavaScript?

Collapse
 
citguy profile image
Ryan Johnson

You could argue that the following syntax is subjectively easier to grok, because it's explicit about the definition and execution of the async function main. However, there's no technical advantage of one syntax vs the other.

async function main () {
  try {
    await something()
  } catch (e) {
    console.error(e.stack)
    process.exit(1)
  }
}

main()