ECMAScirpt6で導入予定のアロー関数とデフォルト引数を組合せた自己再帰関数。
var fact = ((f=n=>n>1?n*f(n-1):1)=>f)();
fact(5); //== 120
引用元
http://d.hatena.ne.jp/teramako/20130321/p1
http://www.mail-archive.com/es-discuss@mozilla.org/msg22135.html
Go to list of users who liked
More than 5 years have passed since last update.
ECMAScirpt6で導入予定のアロー関数とデフォルト引数を組合せた自己再帰関数。
var fact = ((f=n=>n>1?n*f(n-1):1)=>f)();
fact(5); //== 120
引用元
http://d.hatena.ne.jp/teramako/20130321/p1
http://www.mail-archive.com/es-discuss@mozilla.org/msg22135.html
Register as a new user and use Qiita more conveniently
Go to list of users who liked