Skip to content

Instantly share code, notes, and snippets.

@Bambina-zz
Created July 29, 2015 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bambina-zz/4d346dc94bc21a3b72a6 to your computer and use it in GitHub Desktop.
Save Bambina-zz/4d346dc94bc21a3b72a6 to your computer and use it in GitHub Desktop.
js curry function
//2つの引数を取る関数add(x,y)のカリー化
function add(x,y){
return x+y;
}
//これを引数を1つ取り、残りの引数を取って処理結果を返す関数に分解する。
function add(x){
return function(y){ //y1つを取る無名関数を返す。
return x+y;
};
};
console.log(add(1)(2)); //=>3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment