Skip to content

Instantly share code, notes, and snippets.

@mrlannigan
Created December 23, 2014 17:12
Show Gist options
  • Save mrlannigan/68cfb40aa9514239a019 to your computer and use it in GitHub Desktop.
Save mrlannigan/68cfb40aa9514239a019 to your computer and use it in GitHub Desktop.
var timer;
timer = setTimeout(function () {console.log('first timer'); timeoutRun()}, 1000);
timer = setTimeout(function () {console.log('second timer'); timeoutRun()}, 1000);
clearTimeout(timer);
function timeoutRun() {
console.log('Timed out!');
}
var timer;
timer = setTimeout(createTimeoutRun('first'), 1000);
timer = setTimeout(createTimeoutRun('second'), 1000);
clearTimeout(timer);
function createTimeoutRun(text) {
return function () {
console.log(text + ' timer Timed out!');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment