You are reading the documentation for an outdated Corteza release. 2024.9 is the latest stable Corteza release.

Modern JavaScript

About async/await and Promises

If you are not familiar with Promises, we strongly recommend reading MDN article about using promises

In short: Promises solve problem of asynchronous code and remove the need for cumbersome callbacks via function parameters. They provide a simple and readable syntax and error handling via .catch().

About use of await/async syntactic sugar

You will find examples with await prefix. You can not use this on the global scope of the script, it will result in "await is only valid in async function syntax error".

You can, however wrap your code with (async () ⇒ { …​ }()) and place your await calls there.

The arrow function expression (⇒)

MDN article about arrow functions