// setTimeout() = function in JavaScript that allows you to schedule // the execution of a function after an amount of time // Times are approximate // setTimeout(callback, delay); // ---------- EXAMPLE 1 ---------- function hello() { window.alert("Hello"); } setTimeout(hello, 3000); // ---------- EXAMPLE 2 ---------- // clearTimeout() = can cancel a timeout before it triggers const timeoutId = setTimeout(() => window.alert("Hello"), 3000); clearTimeout(timeoutId); // ---------- EXAMPLE 3 ---------- let timeoutId; function showAlert() { window.alert("Hello"); } function startTimer() { timeoutId = setTimeout(showAlert, 3000); console.log("STARTED"); } function clearTime() { clearTimeout(timeoutId); console.log("CLEARED"); } Document START CLEAR
@futuredoctor71487 ай бұрын
1 thousand nah 1 1 thousand, 2 thousand nah 2 1 thousand
@hunin2711 ай бұрын
hey bro, what do you think is a project i could try doing with all of the things we've learned?
@mazinhussein24425 ай бұрын
Hi, the statment "function clearTime() {" must be: "function clearTimer() {"
@nicktorius89103 ай бұрын
I changed "hello" to "too late" so its like you make a game to press clear before the pop up window comes out and says "too late"