This is destructuring a function argument, with default values, plus a default value for the argument as a whole, in case it is omitted entirely
Consider normal destructuring:
{ a, b } = objectWithProps;
which is equivalent to
a = objectWithProps.a;
b = objectWithProps.b;
You can also add default values:
{ a = 5 } = objectWithPropsMaybe;
which is equivalent to
if(objectWithPropsMaybe.a === undefined) {
a = objectWithPropsMaybe.a;
} else {
a = 5;
}
You can also use destructuring on function arguments to create local variables inside a function:
function foo({ a, b }) {
return a + b;
}
foo({ a: 2, b: 3 });
And the destructuring can have default values:
function foo({ a=0, b=0 }) {
return a + b;
}
foo({ a: 2 });
Finally, the destructuring can have a fallback target in case no argument is supplied at all:
function foo({ a=0, b=0 } = {}) {
return a + b;
}
foo();