Timer

Example

setTimeout(() => console.log('Timer finished after 2 seconds'), 2000);

See also:

TSX timer.tsx

Methods

clearInterval(id)

Cancels the running interval associated with the given ID. When given an invalid ID, nothing happens.

Parameter Type Optional Description
id any No The ID that was returned by setInterval.

Returns void

clearTimeout(id)

Cancels the running timeout associated with the given ID. When given an invalid ID, nothing happens.

Parameter Type Optional Description
id any No The ID that was returned by setTimeout.

Returns void

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 Optional Description
callback Function No The function to call.
delay number Yes The delay in milliseconds.
…params any[] No 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 Optional Description
callback Function No The function to call.
delay number Yes The delay in milliseconds.
…params any[] No One or more values passed on to the callback.

Returns any