Skip to content

Instantly share code, notes, and snippets.

@jussi-kalliokoski
Last active August 29, 2015 14:00
Show Gist options
  • Save jussi-kalliokoski/11250536 to your computer and use it in GitHub Desktop.
Save jussi-kalliokoski/11250536 to your computer and use it in GitHub Desktop.
Dealing with function function signatures with multiple arguments.
// The usual way
var prepend = function (string, prefix) {
return prefix.concat(string);
};
prepend("foo", "bar_"); // Wait, what? Is this "foobar_" or "bar_foo"? Not obvious without seeing the function signature.
// More natural language
var prepend = function (string) {
return {
with: function (prefix) {
return prefix.concat(string);
}
};
};
prepend("foo").with("bar_"); // "bar_foo"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment