So imagine we got a function like below, and I want to use the default value for the first parameter a
and a custom value for second parameter b
.
const func = (a = 1 , b = 2) => {
console.log("a is equal to " + a, " and b is equal to " + b)
}
I want to just pass one value for parameter b. something like this:
func(b : 7);
// I want it to print: a is equal to 1 and b is equal to 7
How can I achieve it in JavaScript?