function demo(a,b,c,d=1,e=2,f=3){
console.log(a,b,c,d,e,f); //prints all passed parameters
}
demo(1,2,3,e=5); //calls demo function with the parameter 'e' set to 5
//expected output: 1 2 3 1 5 3
//real output: 1 2 3 5 2 3
function demo(a,b,c,d=1,e=2,f=3){
console.log(a,b,c,d,e,f); //prints all passed parameters
}
demo(1,2,3,e=5); //calls demo function with the parameter 'e' set to 5
//expected output: 1 2 3 1 5 3
//real output: 1 2 3 5 2 3
You need to use the right parameter slot for handing over a value, like
function demo(a, b, c, d = 1, e = 2, f = 3) {
console.log(a, b, c, d, e, f);
}
demo(1, 2, 3, undefined, 5);
Another solution could be an object, like
function demo({ a, b, c, d = 1, e = 2, f = 3 }) {
console.log(a, b, c, d, e, f);
}
demo({ a: 1, b: 2, c: 3, e: 5 });