Skip to main content
Version: Next

setTimeout

function setTimeout(
callback,
delay, ...
args): number;

Set a timer which executes a function or specified piece of code once the timer expires.

Parameters

ParameterTypeDescription

callback

(...args) => void

A function to be executed after the timer expires.

delay

number

(Optional) The milliseconds that the timer should wait before the function is executed, by default is 1.

...args

any[]

(Optional) Additional arguments which are passed through to the function.

Returns

number

The ID (integer) which identifies the timer created.

Throws

Throws TypeError if callback is not a function, or delay is neither a number or undefined.