> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# setInterval() global function

APISummary
Repeatedly calls a function or executes a code fragment with a fixed time interval between each call.

## Syntax

```typescript
setInterval(function: () => void, delay: number): number;
```

### Parameters

#### function

Functions to be called repeatedly are executed after every specified `delay` milliseconds. The first call occurs after `delay` milliseconds.

#### delay

The time interval between repeated function calls, in milliseconds.

The js thread may be frozen while the app is in the background. Therefore, the actual delay of `setInterval` may be greater than the specified value. At the same time, the duration of the js thread being frozen will still be counted in the delay of `setInterval`. In this case, the specified function will only be called once immediately after the app wakes up, even if the js thread is frozen for a number of times longer than `delay`.

### Return value

Returns a positive integer representing the ID value of the timer. This ID value can be used to cancel the timer.

The front-end code should not make any assumptions about the actual value of the returned ID.

## Example

## Compatibility

**Compatibility Table**

**Query:** `lynx-api.global.setInterval`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/global/setInterval.json) · [MDN](https://developer.mozilla.org/en-US/docs/Web/API/setInterval)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| setInterval | Yes (1.3) | Yes (3.4) | Yes (1.3) | Yes (3.5) | Yes (3.5) | Yes |

**`setInterval`**

Repeatedly calls a function or executes a code fragment with a fixed time interval between each call.

**Specifications:**

