Skip to content

Instantly share code, notes, and snippets.

@sevperez
Last active June 24, 2018 18:15
Show Gist options
  • Save sevperez/ab9ed78641a3df8921a75a32140e340d to your computer and use it in GitHub Desktop.
Save sevperez/ab9ed78641a3df8921a75a32140e340d to your computer and use it in GitHub Desktop.
function speak(string) {
console.log(string);
}
var delayedFunction = function(fn) {
return function(val, delay) {
setTimeout(function() {
fn(val);
}, delay);
};
};
var delayedSpeak = delayedFunction(speak);
delayedSpeak("I'm late!", 1000); // logs "I'm late" after a 1 second delay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment