Md Asif Raza
Apr 6, 2022

--

setTimeout() | A Crazy Method

Be with me and get to know everything.

  1. A web API, which we get from the browser.
  2. A Global method that sets a timer and executes a function or a specific piece of code once the timer expires.
  3. Syntax < setTimeout(function[,delay]) >
    function: can be any function that will be executed after the timer expires.
    delay: time in milliseconds that the timer should wait before the specific function or code is executed.
  4. Let's check with an example

In the above pic, we can see that their line-9 is getting consoled first then the line-6.

4. Now to have more clarity we will try to print 1to 10 in a sequence with the difference in timing

Click on the link and see the magic by yourself https://replit.com/@mdasifr28/setimeout#index.js

--

--

Md Asif Raza
0 Followers

Full Stack Developer | MERN | javascript