---
title: setTimeout
summary: The setTimeout() method sets a timer which calls a function once the timer expires.
url: https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/fn.setTimeout/
---

**Kind:** Function  
**Module:** [globals](https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/)  
**Package:** @fastly/js-compute 4.0.1  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2131

```javascript
setTimeout(callback: (...args: TArgs) => void, delay?: number, ...args: any): number
```

The setTimeout() method sets a timer which calls a function once the timer expires.

**See also**

- [setTimeout on MDN](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout)

**Parameters**

- `callback`: `(...args: TArgs) => void` — A function to be called after the timer expires.
- `delay`: `number` (optional) — The time, in milliseconds, that the timer should wait before calling the specified function. Defaults to 0 if not specified.
- `...args`: `any` — Additional arguments which are passed through to the callback function.

**Returns**

`number`

A numeric, non-zero value which identifies the timer created; this value can be passed to clearTimeout() to cancel the timeout.
