Skip to content

Instantly share code, notes, and snippets.



Last active Nov 7, 2016
What would you like to do?
A function which moves argument of passed function from the first position to the last position.
flipArgs = function (f) {
return function() {
let args =;
return f.apply(null, args.slice(1).concat(args[0]))
fullName = function(name, lastName) { return name + ' ' + lastName}
// fullName("John", "Doe") -> "John Doe"
// flipArgs(fullName)("Doe", "John") -> "John Doe"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment