I'm currently trying to figure out how to pass multiple parameter inside a function with the "..." operator while also passing an optional parameter with the "?" operator.
The functions' header shall look like this:
public ThisIsAFunction(val_a: string, val_b?: string, ...val_c: string[]) {};
But since for the "..." - operator it is needed to set the parameter as the last one, but the "?" operator also needs to be set as the last item for being able to leave it without an input, it seems like the only option to use it like that would be:
public ThisIsAFunction("Test", undefined, "Test_one", "Test_two", "Test_three");
But is there also a way to use it without the need of writing "undefined" inside the parameter if I don't want to use val_b?
Thanks in Advance!
nullto omit the value. But yes, in case of ambiguity (like calling this function with two string values, for example) second param will be considered aval_bvalue. That's another reason to use named params btw.