If I have a function declared with two default parameters, like this:
const doSomething = (defaultVal = 'me default', useThis = false) => {
/* ... */
};
And I want to call the function passing in an argument for the second parameter, but have the first argument just use the default value:
doSomething(???, true);
Is there some syntax for telling the function to use the default parameter, or does a real value need to be passed in?
undefined.foo(1, "two", undefined, "hello", 42). Instead use an object as input. It mimics passing in named parameters, so you can pass any you want. The function can then default the rest.