In C# you can do something like that:
class Program
{
static void Main(string[] args)
{
Sum(2, 2, d: 10);
}
static int Sum(int a, int b, int c = 0, int d = 0)
{
return a + b + c + d;
}
}
Is there a way to do something similar with Javascript?
const foo = (a, b, c = 0, d = 0) => a + b + c + d;
And then call this function:
foo(2, 2, d = 10);
Or the only way is call this function this way?
foo(2, 2, undefined, 10);