柯里化
发布日期:2021-05-07 06:43:15 浏览次数:19 分类:精选文章

本文共 496 字,大约阅读时间需要 1 分钟。

柯里化函数

const currying = (fn,args = []) => {       let len = fn.length;    return (..._)=>{           let arg = args.concat(_);        if(arg.length < len){               return currying(fn,arg);        }        return fn(...arg);    }};const add = (a, b, c, d, e) => {     return a + b + c + d + e;};let r = currying(add)(1)(2,3)(4,5);console.log(r);

柯里化类型

const types = ['String','Number','Boolean'];let utils = {   }types.forEach(type=>{       utils[`is${     type}`] = currying(isType)(type);})
上一篇:OSI参考模型|计算机网络
下一篇:组件介绍与按钮|GUI编程

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2025年03月26日 00时16分10秒