Skip to content

Instantly share code, notes, and snippets.

@amiel
Created May 27, 2010 18:35
Show Gist options
  • Save amiel/416167 to your computer and use it in GitHub Desktop.
Save amiel/416167 to your computer and use it in GitHub Desktop.
function curry_timer_func(text) {
var local_var = text.toUpperCase(); // local variable will be bound to the function that is returned
return function() { window.console.log(text, local_var); };
}
window.setTimeout(curry_timer_func("Curried Timer 1"), 1000);
window.setTimeout(curry_timer_func("Curried Timer 2"), 2000);
function setup_another_timer(text, time) {
var local_var = text.toLowerCase();
window.setTimeout(function() { window.console.log(text, local_var); }, time);
}
setup_another_timer("Timer 3", 3000);
setup_another_timer("Timer 4", 4000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment