Created
September 1, 2012 04:42
-
-
Save iamwilhelm/3563975 to your computer and use it in GitHub Desktop.
Default arguments in javascript/coffeescript
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
# Here's a way to do default arguments in coffeescript with combinators | |
defaultArgs = (defaults...) -> | |
(callback) -> | |
(args...) -> | |
callback.apply @, ((arguments[i] || def) for i, def of defaults) | |
# However, coffeescript already supports default arguments, so if you translate it to javascript, | |
# it's a way to do default arguments |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment