Timers

  • You can use the setTimeout function to do things after a certain delay
  • Pass a function (for what to do) and a delay time (in ms)
function printHello() {
    console.log("Hello!");
}

function annoying() {
    console.log("Is this annoying?");
}

setTimeout(printHello, 1000);
setInterval(annoying, 1000);

15 / 21