Javascript setTimeout and setInterval functions

In this blog I will create a small sample demonstrating the usage of javascript setTimeout and setInterval functions.
The difference between setTimeout and setInterval is that the function provided in setTimeout gets called once after the specified delay while in setInterval the specified function gets called repeatedly after the specified delay until we call the clearInterval function. Let's take a look at the code: