Expert Developer JavaScript Question:
Download Questions PDF

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

Expert JavaScript Developer Interview Question
Expert JavaScript Developer Interview Question

Answer:

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.

Download Expert JavaScript Developer Interview Questions And Answers PDF

Previous QuestionNext Question
What is Push() method in JavaScript?What is the difference between JavaScript and JScript?