Function Corialization problem


    // 
    // curry = fn => {
    //     let arr = [];//
    //     judge = (...args)=>{
    //         if(!args[args.length-1]){
    //             return fn(arr);
    //         }else{
    //             arr.push(...args);
    //             return judge;// 
    //         }
    //
    //     };
    //     return judge;
    // }

    // 
    curry = fn => judge = (...args)=>{
        return !args[args.length-1]?fn(args):(...arg)=>judge(...args,...arg);//judge  
    };
    
    
      testCurry = (args)=>{
        args.pop();//null
        if(args.length<1){
            return;
        }
        let sum = args.reduce((s,n)=>{
            return s+n;
        },0);
        console.log("",args);
        console.log("sum",sum);
        return sum;
    };
    
       OnClick =()=>{
        console.log(" OnClick");
        let one = this.curry(this.testCurry)(1);
        let two = one(2)(3)(4)(5);
        let three = two(6,6,6,6);
        three(null);
    };

how does the second function understand how she saves the previously entered parameters?
Thank you for a detailed answer


judge is not executed immediately, but at (.arg) = > judge (.args, .arg); method is executed only when
the function after curry starts execution only when the last parameter passed can be converted to false . The method of storing parameters is also very simple
1. To determine whether the last parameter can be false
2, if so, put all saved parameters into fn and end
3, otherwise, return a new anonymous function. This function stores all incoming parameters in the arg array, and after the anonymous function is executed, it merges the previously received parameter array with the current parameter array, puts it into the logic mentioned above, judges in the judge function, and repeats step 1

.
let curry = function(fn) {
    var judge = function(...args) {
        if (Boolean(args[args.length - 1])===false) {
            return fn(args);//three(null)
        } else {
            return function(...arg) { //onetwothree
                return judge(...args, ...arg);
            }
        }
    }
    return judge;
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b39b2b-2c196.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b39b2b-2c196.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?