setTimeout()
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.
Signature
setTimeout(callbackFunction: Function, delay: number)
Parameters
callbackFunction
A function you want to call once a delay
timer (in milliseconds) has passed.
delay
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);