Search code snippets, questions, articles...

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");
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

Live Demo

Was this helpful?