美文网首页
函数柯里化

函数柯里化

作者: 昊哇恰 | 来源:发表于2020-11-24 16:02 被阅读0次

    高程二十二章中有介绍

      function curry (fn) {
                console.log(arguments)
                var args = Array.prototype.slice.call(arguments, 1)
                console.log(args)
                return function() {
                    var innerArgs = Array.prototype.slice.call(arguments)
                    console.info(innerArgs)
                    var finalArgs = args.concat(innerArgs)
                    console.info(finalArgs)
                    return fn.apply(null, finalArgs)
                }
            }
    

    先提供柯理化函数模板便于记录,待用熟用明白再来分享。

    相关文章

      网友评论

          本文标题:函数柯里化

          本文链接:https://www.haomeiwen.com/subject/ihoiiktx.html