函数柯里化通用函数

函数柯里化通用函数

 

答:

 

function curry(func) {

// Array.prototype.slice.call(arguments, 1)

    let args = [].slice.call(arguments, 1);

    return function() {

// Array.prototype.slice.call(arguments)

        let innerArgs = [].slice.call(arguments);

// ES6数组扩展运算符[…],数组合并也可以用concat()

        let finalArgs = [...args, ...innerArgs];

扫描二维码关注公众号,回复: 5698973 查看本文章

        return func.apply(null, finalArgs);

    }

}

猜你喜欢

转载自blog.csdn.net/xif3681/article/details/88873981