A Simple Timer In JavaScript

LEVEL: Beginner

Whats in this post?

  1. Code
  2. Output
  3. Background and Explanation of the code

Code


To copy code: Click  View Source “View Source” on the right of this code snippet.

Background and Explanation of the code


The program exaplains how following methods in javascript can be used for making a simple timer. The two key methods that are used are:

  • setTimeout() – executes a code some time in the future
  • clearTimeout() – cancels the setTimeout()