1var count = 0;
2 function updateCount() {
3 count = count + 1;
4 document.getElementById("number").innerHTML = count;
5 setTimeout(updateCount, 1000);
6 }
1//single event i.e. alarm, time in milliseconds
2var timeout = setTimeout(function(){yourFunction()},10000);
3//repeated events, gap in milliseconds
4var interval = setInterval(function(){yourFunction()},1000);
1// this example takes 2 seconds to run
2const start = Date.now();
3
4// After a certain amount of time, run this to see how much time passed.
5const milliseconds = Date.now() - start;
6
7console.log('Seconds passed = ' + millis / 1000);
8// Seconds passed = *Time passed*