Currying and Bind

Currying is a technique to bind a function to a subset of arguments (Effective JavaScript by David Herman, p.75). In the example, we can see that two arguments (protocol and domain) are passed as the arguments of the function simpleURL, when it is used in the higher-order function, that is - map method. The third argument "path" comes from each array element of the iteration of the map method.

var paths = ["fruit", "veggie", "bread"];

function simpleURL(protocol, domain, path) {
    return protocol + "://" + domain + "/" + path;

var urls = {
    return simpleURL("http", "", path)

//["", "", ""]

This can be concisely written using currying and bind like this.

var urls =, "http", ""));