In "Understanding ECMAScript6",
[The] default object needs to have all the same information as the destructured parameters (with the same defaults, to ensure consistent behavior), like the one in this version of the setCookie() function:
function setCookie(name, value,
{
secure = false,
path = "/",
domain = "example.com",
expires = new Date(Date.now() + 360000000)
} = {
secure: false,
path: "/",
domain: "example.com",
expires: new Date(Date.now() + 360000000)
}
) {
// ...
}
My question is why not simply set the destructuring object to an empty object? Why does it need to be an object with the same information? I cannot perceive any "win" from duplicating the defaults.
Indeed, it is duplicative and unnecessary; cf https://github.com/nzakas/understandinges6/issues/255