How should js pass an indefinite number of parameters?

want to customize a log function to output not only in the console, but also in the text box

log(obj)=>{
    console.log(obj)
}

but console.log () can pass N parameters, such as console.log, ,
, and how should I write my custom log,? log (apdre bpender) = > {} doesn"t seem to be the case.
I vaguely remember that some source code seems to say log (arg.) = > {} , and then I go to Baidu. But all of them are less than Baidu, so I came here to ask the great god, how should I write this indefinite number of parameters?

Mar.20,2021

before es6, arguments is generally used as a way to obtain parameters for indefinite parameter transmission, such as

function abc(){
    var len=arguments.length;
    for(var i=0;i<len;iPP){
        console.log(""+i+":"+arguments[i]+"\n");
    }
}

abc("a","b");
< hr >

in es6
can use . to name an indefinite parameter name, so that it has a more meaningful parameter name than the previous version. It should be noted that the indefinite parameter can only be the last parameter, and there can only be one indefinite parameter in a function definition
for example:

.
function abc1(...vars){
    let len = vars.length;
    for(let i=0;i<len;iPP){
        console.log(""+i+":"+vars[i]+"\n");
    }
}

function abc3(name,...vars){
    let len = vars.length;
    for(let i=0;i<len;iPP){
        console.log("name"+name+""+i+":"+vars[i]+"\n");
    }
}

is looking for arguments or function (a, .args) {}; Bar


I don't know if this is it.

    function test(...a){
        console.log(a,...a);
        if(a[0]){ // 
           // do something
        }
         if(a[1]){ // 
           // do something
        }
        ....
    }
    test(1,2,3) 

all argument arrays, arguments

Menu