Developer Blog

Developer Blog

Javascript Timer APIs

Javascript Timer APIs

Subscribe to my newsletter and never miss my upcoming articles

Listen to this article

Hello Developers!! Today we will discuss the different timers API used in Javascript

  • setTimeout
  • setInterval


It delays an operation for a certain amount of time which is passed as a parameter.

It takes two parameters:

  • a function
  • delay time in millisecond
    console.log("setTimeout in action");
}, 2000)

In the above code snippet, it will print to the console after 2000 ms.

Now look at another example of setTimeout:-

let myFunc = (num1, num2) => {
    console.log(num1, "---", num2);

setTimeout(myFunc, 2000, 2, 3);


If you pass more than 2 parameters in the setTimeout then this will eventually become the parameters of the myFunc.


It puts a delayed operation in a loop

    console.count("setInterval in action")


Wrap Up!!

Thank you for your time!! Let's connect to learn and grow together.

LinkedIn Twitter Instagram


Share this