---
title: setInterval
summary: The setInterval() method repeatedly calls a function, with a fixed time delay between each call. This method returns an interval ID which uniquely identifies the interval, so you can remove it later by calling clearInterval().
url: https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/fn.setInterval/
---

**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#L2158

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

The setInterval() method repeatedly calls a function, with a fixed time delay between each call.
This method returns an interval ID which uniquely identifies the interval, so you can remove it later by calling clearInterval().

**See also**

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

**Parameters**

- `callback`: `(...args: TArgs) => void` — A function to be called every delay milliseconds. The first call happens after delay milliseconds.
- `delay`: `number` (optional) — The time, in milliseconds, that the timer should delay in between calls of 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 clearInterval() to cancel the interval.
