What does the following JavaScript code print (console output, as in Node.js)?
function f({ a = 1, b } = { b: 2 }) {
return `${a}-${b}`;
}
console.log(f(), f({}), f({ b: 5 }));
The default object { b: 2 } is used only when no argument (undefined) is passed. f({}) passes an object without b, so b is undefined; a always falls back to 1.