JavaScript setTimeout function provides the functionality to execute the specified function after the sepcified number of milliseconds. Using the JavaScript setTimeout function you can set the delay before function execution. For example you want to display any ad on your HTML web page only if the user stays on it for more than 5 seconds then you can set the delay of 5000 milliseconds to call that function.
Try the sample code below to learn and practice the JavaScript setTimeout function: