Created
October 14, 2014 19:08
-
-
Save Qard/ae3a06888c8a6b8ace70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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