Skip to content

Instantly share code, notes, and snippets.

@prof3ssorSt3v3
Created July 22, 2017 22:18
Show Gist options
  • Save prof3ssorSt3v3/d87fb723d2d08d57d365e9a066278ba2 to your computer and use it in GitHub Desktop.
Save prof3ssorSt3v3/d87fb723d2d08d57d365e9a066278ba2 to your computer and use it in GitHub Desktop.
// setTimeout
// How to use setTimeout, clearTimeout, setInterval
// and clearInterval
//
function log(msg){
console.log('MESSAGE', msg);
clearInterval(tommy);
}
let timmy = setTimeout(log, 2000, 'Hello', 12, true);
//1000 means 1 second
clearTimeout(timmy);
let tommy = setInterval(log, 500, 'Goodbye');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment