If you want to call a function after a specific amount of time, just like using a timer, you can call setTimeout() or setInterval() function.

setTimeout() is for single execution, and setInterval() will run repeatedly after we stop it.

Here is two video tutorial about setTimeout() and setInterval() and in the end of this post you can see the source code you see in the video.

Source code:

Related Post

JavaScript setTimeout() and setInterval() tutorial