Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【🍣】函数柯里化 #78

Open
Easay opened this issue May 8, 2021 · 0 comments
Open

【🍣】函数柯里化 #78

Easay opened this issue May 8, 2021 · 0 comments
Labels

Comments

@Easay
Copy link
Owner

Easay commented May 8, 2021

function curryIt(fn){
    var args = [];
    return function() {
        // 类数组转数组方式1:
        var arg = [].slice.call(arguments);
        // 方式2:
        //var arg = Array.from(arguments);
        args = args.concat(arg);
        if(args.length < fn.length){
            return arguments.callee;
        }else{
            return fn.apply(null,args);
        }
    }   
}
@Easay Easay added the 手撕 label May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant