JavaScript中的Compose函数

JavaScript中的Compose函数,javascript,Javascript,我试图从下面的代码中获得一些详细信息: const upperCase=str=>str.toUpperCase; 常量惊叹号=str=>`${str}!`; const repeat=str=>`${str}`.repeat3; const compose=…fns=>x=>fns.reduceRightacc,fn=>fnacc,x; 含Сcompose的常数=合成 重复 呼喊 大写字母 ; 控制台。logwithСomposehello 1.2。因为reduce right接受两个参数r

我试图从下面的代码中获得一些详细信息:

const upperCase=str=>str.toUpperCase; 常量惊叹号=str=>`${str}!`; const repeat=str=>`${str}`.repeat3; const compose=…fns=>x=>fns.reduceRightacc,fn=>fnacc,x; 含Сcompose的常数=合成 重复 呼喊 大写字母 ;
控制台。logwithСomposehello 1.2。因为reduce right接受两个参数reduceRightreducer,initialValue 在您的例子中,初始值是x本身

const upperCase=str=>str.toUpperCase; 常量惊叹号=str=>`${str}!`; const repeat=str=>`${str}`.repeat3; const reducer=acc,fn=>fnacc; const compose=…fns=>x=>fns.reduceRightreducer,x; 含Сcompose的常数=合成 重复 呼喊 大写字母 ;
控制台。logwithСomposehello 1.2。因为reduce right接受两个参数reduceRightreducer,initialValue 在您的例子中,初始值是x本身

const upperCase=str=>str.toUpperCase; 常量惊叹号=str=>`${str}!`; const repeat=str=>`${str}`.repeat3; const reducer=acc,fn=>fnacc; const compose=…fns=>x=>fns.reduceRightreducer,x; 含Сcompose的常数=合成 重复 呼喊 大写字母 ;
控制台。logwithСomposehello 可能有助于了解撰写的结果:

含Сompose的常数=函数FnPowerCaseStr1{ const resultStrFn1=str1.toUpperCase; 返回函数fnequimstr2{ const resultStrFn2=`${str2}!`; 返回函数FNSTR3{ 返回`${str3}`.repeat3; }结果TRFN2; }结果TRFN1; };
控制台。带有Сcompose'hello'的日志 可能有助于了解撰写的结果:

含Сompose的常数=函数FnPowerCaseStr1{ const resultStrFn1=str1.toUpperCase; 返回函数fnequimstr2{ const resultStrFn2=`${str2}!`; 返回函数FNSTR3{ 返回`${str3}`.repeat3; }结果TRFN2; }结果TRFN1; };
控制台。带有Сcompose'hello'的日志;将箭头函数替换为其旧的学校函数版本。这可能更容易理解。非常相关:用老版本的函数替换箭头函数。这可能更容易理解。非常相关:只有一个必需参数->减速器。initialValue是可选的。@Shandor Kostur,我理解对了吗,写这个:用СcomposeHello,我创建了一个curried函数,本例中的hello将代替x作为initialValue?@AskMen更具体地说,您已经创建了部分应用程序而不是curried函数,但您是对的,在本例中hello是reduce right的initialValue,只有一个必需参数->reducer。initialValue是可选的。@Shandor Kostur,我理解对了吗,写这个:用СcomposeHello,我创建了一个curried函数,本例中的hello将代替x作为初始值?@AskMen更具体地说,您创建了部分应用程序而不是curried函数,但是的,您在本例中是对的hello是reduce right的初始值。请看一看,谢谢:请看一看,谢谢: