Skip to content

Instantly share code, notes, and snippets.

@Qard
Created October 14, 2014 19:08
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 Qard/ae3a06888c8a6b8ace70 to your computer and use it in GitHub Desktop.
Save Qard/ae3a06888c8a6b8ace70 to your computer and use it in GitHub Desktop.
function times (n, fn) {
return function () {
if (n > 0) {
n--
return fn.apply(this, arguments)
}
}
}
var hello = times(2, function () {
console.log('hello')
})
hello() // hello
hello() // hello
hello()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment