In Javascript I defined a function with one require parameter and some optional parameters. But when I want to call the function with only some optional parameter, then I am facing the problem.
function foo(par1, par2='default_value1', par3='default_value2', par4='default_value3'){
//do the stuff
}
It works-
foo('some_value');
foo('some_value', par1='some_value');
foo('some_value', par1='some_value', par2='some_value');
But it's not works-
foo('some_value', par1='some_value', par4='some_value');
In this case, value of "par4" automatically assigned to "par3" during the execution of the function. I.e. value of par3 will be "some_value"