function - Pass only the second argument in javascript - Stack Overflow

PHOTO EMBED

Thu Jun 02 2022 09:34:56 GMT+0000 (Coordinated Universal Time)

Saved by @awadkhaled #javascript

function test(a = "ay", b = "bee") {
  console.log(`a = ${a}, b = ${b}`);
}
test();             // "a = ay, b = bee"
test(1);            // "a = 1, b = bee"
test(undefined, 2); // "a = ay, b = 2"
test(1, 2);         // "a = 1, b = 2"
content_copyCOPY

https://stackoverflow.com/questions/50569300/pass-only-the-second-argument-in-javascript