Timer
Examples
JavaScript
setTimeout(() => console.log('Timer finished after 2 seconds'), 2000);
See also:
Methods
clearInterval(id)
Cancels the running interval associated with the given ID. When given an invalid ID, nothing happens.
Parameter | Type | Description |
---|---|---|
id | any |
The ID that was returned by setInterval . |
Returns: undefined
clearTimeout(id)
Cancels the running timeout associated with the given ID. When given an invalid ID, nothing happens.
Parameter | Type | Description |
---|---|---|
id | any |
The ID that was returned by setTimeout . |
Returns: undefined
setInterval(callback, delay?, …params)
Calls the given function repeatedly, each times waiting the given delay. The actual delay may be slightly longer than the given one.
Parameter | Type | Description |
---|---|---|
callback | Function |
The function to call. |
delay | number |
The delay in milliseconds. Optional. |
…params | any[] |
One or more values passed on to the callback. |
Returns: any
setTimeout(callback, delay?, …params)
Calls the given function with param
(and all following parameters) after the specified delay. The actual delay may be slightly longer than the given one.
Parameter | Type | Description |
---|---|---|
callback | Function |
The function to call. |
delay | number |
The delay in milliseconds. Optional. |
…params | any[] |
One or more values passed on to the callback. |
Returns: any