What does a timer do and how would you implement one?

Submitted by: Administrator
Setting timers allows you to execute your code at predefined times or intervals.
This can be achieved through two main methods: setInterval(); and setTimeout();
setInterval() accepts a function and a specified number of milliseconds.
ex) setInterval(function(){alert("Hello, World!"),10000) will alert the "Hello, World!" function every 10 seconds.
setTimeout() also accepts a function, followed by milliseconds. setTimeout() will only execute the function once after the specified amount of time, and will not reoccur in intervals.
Submitted by:

Read Online Expert Developer JavaScript Job Interview Questions And Answers