Created
April 20, 2015 03:29
-
-
Save davidchase/5f9c21f6f70528d77c25 to your computer and use it in GitHub Desktop.
partial + partialRight
This file contains hidden or 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
var partial = function partial(fn){ | |
var args = Array.apply(null, arguments).slice(1); | |
return function(){ | |
var lastArgs = Array.apply(null, arguments); | |
return fn.apply(this, args.concat(lastArgs)); | |
}; | |
}; | |
var partialRight = function partialRight(fn){ | |
var args = Array.apply(null, arguments).slice(1); | |
return function(){ | |
var firstArgs = Array.apply(null, arguments); | |
return fn.apply(this, firstArgs.concat(args)); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment