>The initial APIs of this module are supported since API version 4. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> **NOTE:** The initial APIs of this module are supported since API version 4. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Module to Import<a name="section7480141454919"></a>
<td class="cellrowborder" valign="top" width="62.91%" headers="mcps1.1.5.1.4 "><p id="p788516491307"><a name="p788516491307"></a><a name="p788516491307"></a>Function to be called after the timer goes off.</p>
<td class="cellrowborder" valign="top" width="62.91%" headers="mcps1.1.5.1.4 "><p id="p1943234615"><a name="p1943234615"></a><a name="p1943234615"></a>Number of milliseconds delayed before the execution. If this parameter is left empty, the default value <strong id="b1264512254010"><a name="b1264512254010"></a><a name="b1264512254010"></a>0</strong> is used, which means that the execution starts immediately or as soon as possible.</p>
<td class="cellrowborder" valign="top" width="62.91%" headers="mcps1.1.5.1.4 "><p id="p139991022863"><a name="p139991022863"></a><a name="p139991022863"></a>Additional parameter to pass to the handler after the timer goes off.</p>
<td class="cellrowborder" valign="top" width="69.94%" headers="mcps1.1.5.1.4 "><p id="p6426183941319"><a name="p6426183941319"></a><a name="p6426183941319"></a>ID of the timer to cancel, which is returned by <strong id="b5804644564"><a name="b5804644564"></a><a name="b5804644564"></a>setTimeout()</strong></p>
| handler | Function | Yes | Function to be called after the timer goes off. |
| delay | number | No | Number of milliseconds delayed before the execution. If this parameter is left empty, the default value **0** is used, which means that the execution starts immediately or as soon as possible. |
| ...args | Array\<any> | No | Additional parameter to pass to the handler after the timer goes off. |
- Return Value
| Type | Description |
| ------ | ----------- |
| number | Timer ID. |
- Example
```
export default {
setTimeOut() {
var timeoutID = setTimeout(function() {
console.log('delay 1s');
}, 1000);
}
```
}
```
## clearTimeout
## setInterval<a name="section3644185910144"></a>
clearTimeout(timeoutID: number): void
setInterval\(handler\[, delay\[, ...args\]\]\): number
Cancels the timer created via **setTimeout()**.
Sets a repeating timer for the system to repeatedly call a function at a fixed interval.
<td class="cellrowborder" valign="top" width="62.91%" headers="mcps1.1.5.1.4 "><p id="p4645155931418"><a name="p4645155931418"></a><a name="p4645155931418"></a>Function to be called repeatedly</p>
<td class="cellrowborder" valign="top" width="62.91%" headers="mcps1.1.5.1.4 "><p id="p13645559141415"><a name="p13645559141415"></a><a name="p13645559141415"></a>Number of milliseconds delayed before the execution</p>
<td class="cellrowborder" valign="top" width="62.91%" headers="mcps1.1.5.1.4 "><p id="p12645105991413"><a name="p12645105991413"></a><a name="p12645105991413"></a>Additional parameter to pass to the handler after the timer goes off</p>
<td class="cellrowborder" valign="top" width="69.94%" headers="mcps1.1.5.1.4 "><p id="p7646459141416"><a name="p7646459141416"></a><a name="p7646459141416"></a>ID of the repeating timer to cancel, which is returned by <strong id="b1855918269134"><a name="b1855918269134"></a><a name="b1855918269134"></a>setInterval()</strong>.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
export default {
clearInterval() {
var intervalID = setInterval(function() {
console.log('do very 1s.');
}, 1000);
clearInterval(intervalID);
}
}
```
## setInterval
setInterval(handler[, delay[, ...args]]): number
Sets a repeating timer for the system to repeatedly call a function at a fixed interval.