JavaScript: setTimeout en setInterval

JavaScript: setTimeout en setInterval

setTimeout en setInterval (voor mij) de meest bruikbare functies van Javascript

setTimeout(function(){ alert("Hello"); }, 3000);

The setTimeout() method calls a function or evaluates an expression after a specified number of milliseconds.
1000 ms = 1 second.
The function is only executed once. If you need to repeat execution, use the setInterval() method.
Use the clearTimeout() method to prevent the function from running.

var myVar;

function myFunction() {
  myVar = setInterval(alertFunc, 3000);
}

function alertFunc() {
  alert("Hello!");
}
Reageren is niet mogelijk.