# Web standards

Azion Runtime runs JavaScript built on Web standards, so the native JavaScript APIs, such as the `Math` and `JSON` objects, are available to a function. For the global objects the runtime defines, refer to [Globals](/en/documentation/devtools/runtime/api-reference/azion-runtime-globals/). For more information on the language, refer to [JavaScript reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference) on MDN Web Docs.

> **Note**
>
> Under `azion dev`, a string passed to `setTimeout()` throws a `TypeError` on the `callback` argument instead of the `EvalError` that a deployed function throws.

---

## Native JavaScript and Web APIs

Native JavaScript objects and the Web APIs of the runtime work together in one function. A function parses a request body with `JSON`, computes values with `Math`, `Date`, and `String`, and returns the result with `Response`. For the Web APIs that Azion Runtime supports, refer to [Web APIs](/en/documentation/devtools/runtime/api-reference/javascript/). For the standard definitions of those APIs, refer to [Web APIs](https://developer.mozilla.org/en-US/docs/Web/API) on MDN Web Docs.

---

## Timer callbacks

A deployed function refuses a string as the callback of `setTimeout()` or `setInterval()`. The call throws `EvalError: eval not allowed on setTimeout/setInterval parameter`. Pass a function as the callback instead.

---

## Use cases

- Parse and serialize payloads with the `JSON` object as requests pass through a function.
- Calculate, format, and transform data with the standard `Math`, `Date`, and `String` methods.
- Write portable logic, test it under `azion dev`, and confirm it on a deployed function. For the APIs that behave differently on each side, refer to [How Azion Runtime works](/en/documentation/devtools/runtime/how-it-works/).
- Combine native language features with the supported Web APIs to build responses on Azion's distributed infrastructure.

---

## Example

This handler passes a string to `setTimeout()`, catches the error the call throws, and returns the error as the response text:

```javascript
export default {
  async fetch(request, env, ctx) {
    const result = await new Promise((resolve) => {
      try {
        setTimeout('globalThis.flag = 1', 0);
        setTimeout(() => resolve(`string callback ran: ${globalThis.flag === 1}`), 20);
      } catch (error) {
        resolve(`${error.name}: ${error.message}`);
      }
    });
    return new Response(result);
  },
};
```

A deployed function returns this text:

```text
EvalError: eval not allowed on setTimeout/setInterval parameter
```

---

## Related resources

- [Web APIs](/en/documentation/devtools/runtime/api-reference/javascript.md): Every Web API that Azion Runtime supports, grouped by family.
- [fetch](/en/documentation/devtools/runtime/api-reference/fetch.md): How a function sends a request and reads the response.
- [node:timers](/en/documentation/devtools/runtime/node/timers.md): The Node.js timer functions, including the promise-based timers.
- [How Azion Runtime works](/en/documentation/devtools/runtime/how-it-works.md): Where `azion dev` differs from a deployed function, API by API.
