> For the complete documentation index, see [llms.txt](https://openai.gitbook.io/code-cheatsheets/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://openai.gitbook.io/code-cheatsheets/js/timeout.md).

# Timeout

```javascript
if(this.timerID !== undefined) {
  clearTimeout(this.timerID);
}
this.timerID = setTimeout(this.sendPayload, 4000);
```

## Interval

```javascript
if(this.timerID !== undefined) {
    clearInterval(intervalID);
}
const intervalID = setInterval(() => alert("Hello"), 3000);
```
