| description | setTimeout() reference |
|---|---|
| toc_max_heading_level | 2 |
This page provides information about the setTimeout() function signature and parameters, which allows you to execute a code once after a specified amount of time has passed. This function is commonly used to introduce delays, handle timed events, or perform actions after a certain interval.
setTimeout(callbackFunction: Function, delay: number)A function you want to call once a delay timer (in milliseconds) has passed.
The time in milliseconds to wait before calling the callbackFunction.
Example: You can use the showAlert() function to show an alert message when delay time has passed as shown below:
setTimeout(() => { showAlert("5 seconds have passed") }, 5000);