javascript

Pass multiple arguments when calling a function which takes single argument Javascript

You can use ... before any parameter name if you are undecided how many arguments will be there when calling a function

function func_name(...allArgs) {
    console.log("Paraameter at 3th position : " + arguments[2]);
    console.log("Paraameter at 6th position : " + arguments[5]);
}

func_name("value1", "value2", "value3", "value4", "value5", "value6");

Live Demo

Was this helpful?