timers in JavaScript

Home Forums Java Script timers in JavaScript

This topic contains 1 reply, has 2 voices, and was last updated by  Sushmita Ghosh 3 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1380

    nayak.anjali.hyd
    Participant

    Explain the working of timers in JavaScript? Also elucidate the drawbacks of using the timer, if any?

    #1381

    Sushmita Ghosh
    Keymaster

    Timers are used to execute a piece of code at a set time or also to repeat the code in a given interval of time. This is done by using the functions setTimeout, setInterval and clearInterval.

    The setTimeout(function, delay) function is used to start a timer that calls a particular function after the mentioned delay. The setInterval(function, delay) function is used to repeatedly execute the given function in the mentioned delay and only halts when cancelled. The clearInterval(id) function instructs the timer to stop.

    Timers are operated within a single thread, and thus events might queue up, waiting to be executed.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Pasham Technology © 2018 Pasham Technologies