🔸rest parameters as object

🚧 under construction

JSobjectfunctionparameter ⟩ 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