Skip to content

Latest commit

 

History

History
46 lines (27 loc) · 1.12 KB

File metadata and controls

46 lines (27 loc) · 1.12 KB
description setTimeout() reference
toc_max_heading_level 2

setTimeout()

This page provides information about the setTimeout() function signature and parameters, which allows you to execute a code once after a specified amount of time has passed. This function is commonly used to introduce delays, handle timed events, or perform actions after a certain interval.

Signature

setTimeout(callbackFunction: Function, delay: number)

Parameters

callbackFunction

A function you want to call once a delay timer (in milliseconds) has passed.

delay

The time in milliseconds to wait before calling the callbackFunction.

Example: You can use the showAlert() function to show an alert message when delay time has passed as shown below:

setTimeout(() => { showAlert("5 seconds have passed") }, 5000);

See also

setInterval()
clearInterval()