setTimeout()
The setTimeout() method schedules a callback function after a specific duration.
Syntax
var timeoutId = setTimeout(callback, msecs [, parameters]);
| timeoutId | An identifier that is associated with the timeout event. This identifier can be used to cancel the timeout event with the clearTimeout() method. |
| callback | The asynchronous function to be called after the system waits for the specified milliseconds. |
| msecs | The number of milliseconds to wait. |
| parameters | The optional, comma-separated parameters to pass to the callback function. |
The setTimeout() method schedules a one-time callback after the specified time in milliseconds. The method immediately returns an identifier for the timeout event. You can use this ID to cancel the scheduled callback function with the clearTimeout() method.
The clearTimeout() method cancels the timer to prevent the triggering of a previously scheduled callback function.