在JavaScript中,你可以通过以下几种方式来清空定时器:
1. 使用`clearTimeout()`函数来清除使用`setTimeout()`设置的定时器。
2. 使用`clearInterval()`函数来清除使用`setInterval()`设置的定时器。
以下是如何使用这些函数的示例:
清除`setTimeout()`设置的定时器
```javascript
// 设置一个定时器
var timerId = setTimeout(function() {
console.log('定时器触发');