Keys in Destructured Parameters Can Have Default Parameters
Below is an example.
const obj1 = {};
const obj2 = { k: 2 };
function fn({ k = 1 }) {
console.log(k);
}
fn(obj1); // 1
fn(obj2); // 2
Below is an example.
const obj1 = {};
const obj2 = { k: 2 };
function fn({ k = 1 }) {
console.log(k);
}
fn(obj1); // 1
fn(obj2); // 2