Skip to content

Instantly share code, notes, and snippets.

@kironroy
Created July 8, 2023 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kironroy/84a17bfabea2209d702eefc52bafa543 to your computer and use it in GitHub Desktop.
Save kironroy/84a17bfabea2209d702eefc52bafa543 to your computer and use it in GitHub Desktop.
set time out
// setTimeout
const ingredients = ['olives', 'anchovies'];
const pizzaTimer = setTimeout(
(ing1, ing2) => console.log(`Here is your pizza with ${ing1} and ${ing2} 🍕`),
3000,
...ingredients
);
console.log('Waiting...');
// will not rnder
if (ingredients.includes('anchovies')) clearTimeout(pizzaTimer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment