When I saw the knowledge points that I couldn't understand and use when I came to the interview questions, I asked the boss for help.

implement such a function

foo (1) 2) / / 3
foo (2) 3) (4) 5) / / 14
foo (2) (2) (2) (8) / / 14

Apr.05,2021

function foo(...args){
    let sum=0;
    for(const value of args){
        sum+=value;
    }
    function result(...args1){
        return foo(sum,...args1);
    }
    result.valueOf=function(){return sum};
    return result;
}
foo(1,2)+0
foo(2,3)(4,5)+0
foo(2)(2)(2)(8)+0

// ES5
function add(){
    var args = [].slice.apply(arguments)
    
    function result() {
        return add.apply(null, args.concat([].slice.apply(arguments)))
    }
    
    result.valueOf = function() {
        return args.reduce(function(sum, x) {
            return sum + x
        }, 0)
    }
    
    return result
}
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-1b370f9-4d700.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-1b370f9-4d700.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?