window.setTimeout
setTimeout — Executes a code snippet or a callable after specified delay.
Description
setTimeout(mixed executable, [integer delay, [mixed param, …]])
Parameters
Name | Description | Type | Default | Optional |
---|---|---|---|---|
executable | Callable name or code snippet. | mixed | No | |
delay | Minimum time in milliseconds before execution. | integer | Yes | |
param, … | All following parameters will be passed to the callable. | mixed | Yes |
Return values
Returns the id of the current interval.
This id can later be used with: clearTimeout.
Examples
Example #1 – setTimeout example
Logs out: First then Third then Second.
Example #2 – Passing parameters
Passing one or more parameters to the function.
Example #3 – Recursive
Recursivly executes 2 seconds after last execution.
Same as above but output is moved to the end of the wait time.
See also
clearTimeout