๐ธrest parameters as object
๐ง under construction
JS โฉ object โฉ function โฉ parameter โฉ rest parameters as object
๐ง
๐พ ็จๅผ๏ผreplit
const { log } = console;
function f({ // parameter destructuring
hi = 0, // default parameter
...opts // rest params as an object โญ๏ธ
} = {}) // default parameter
{
log(hi);
log(opts);
}
// test run
f(); // 0, {}
f({ x: 1, y: 2, hi: 3 }); // 3, { x: 1, y: 2 }
Last updated
Was this helpful?