setTimeout()

The setTimeout() method schedules a callback function after a specific duration.

Syntax

var timeoutId = setTimeout(callback, msecs [, parameters]);
timeoutIdAn identifier that is associated with the timeout event. This identifier can be used to cancel the timeout event with the clearTimeout() method.
callbackThe asynchronous function to be called after the system waits for the specified milliseconds.
msecsThe number of milliseconds to wait.
parametersThe 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.